diff options
author | Abinoam P. Marques Jr <abinoam@gmail.com> | 2017-06-29 22:43:52 -0300 |
---|---|---|
committer | Abinoam P. Marques Jr <abinoam@gmail.com> | 2017-06-29 22:47:03 -0300 |
commit | d5f84faebbd8c5aa8e451cf9a0547247812e57ee (patch) | |
tree | f472bf41a9a09286e0cf01a5571ee25421760243 | |
parent | d6316303929cd822667eaa92e0a7fe21cfceb004 (diff) | |
download | highline-d5f84faebbd8c5aa8e451cf9a0547247812e57ee.tar.gz |
Simplify color_code with delegation
-rwxr-xr-x | lib/highline.rb | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/highline.rb b/lib/highline.rb index 5614980..09dd904 100755 --- a/lib/highline.rb +++ b/lib/highline.rb @@ -47,7 +47,7 @@ class HighLine extend SingleForwardable def_single_delegators :@default_instance, :agree, :ask, :choose, :say, :use_color=, :use_color?, :reset_use_color, - :track_eof=, :track_eof?, :color + :track_eof=, :track_eof?, :color, :color_code def self.default_instance @default_instance @@ -330,15 +330,12 @@ class HighLine # s.code # => "\e[31m\e[34m" # # HighLine.color_code(:red, :blue) # => "\e[31m\e[34m" - - def self.color_code(*colors) - Style(*colors).code - end - - # (see HighLine.color_code) - # Convenience instance method. It delegates to the class method. + # + # cli = HighLine.new + # cli.color_code(:red, :blue) # => "\e[31m\e[34m" + # def color_code(*colors) - self.class.color_code(*colors) + HighLine.Style(*colors).code end # Remove color codes from a string. |