diff options
author | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-12-14 07:15:04 -0300 |
---|---|---|
committer | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-12-14 07:15:04 -0300 |
commit | 01eb0071447800a40bfb84692de3d9082f308c9b (patch) | |
tree | c3ef50678013172424a029aee2c37b96224e4746 | |
parent | 41ad47dde24d5de05bc3bdd8bb1633efeb391043 (diff) | |
download | highline-01eb0071447800a40bfb84692de3d9082f308c9b.tar.gz |
Improve HighLine::StringExtensions documentation
-rw-r--r-- | lib/highline/string_extensions.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/highline/string_extensions.rb b/lib/highline/string_extensions.rb index ec51ced..1899e6b 100644 --- a/lib/highline/string_extensions.rb +++ b/lib/highline/string_extensions.rb @@ -1,6 +1,9 @@ # coding: utf-8 class HighLine + # Returns a HighLine::String from any given String. + # @param s [String] + # @return [HighLine::String] from the given string. def self.String(s) HighLine::String.new(s) end @@ -8,11 +11,18 @@ class HighLine # HighLine extensions for String class. # Included by HighLine::String. module StringExtensions + # Included hook. Actions to take when being included. def self.included(base) define_builtin_style_methods(base) define_style_support_methods(base) end + # At include time, it defines all basic style + # support method like #color, #on, #uncolor, + # #rgb, #on_rgb and the #method_missing callback + # @return [void] + # @param base [Class, Module] the base class/module + # def self.define_style_support_methods(base) base.class_eval do undef :color if method_defined? :color @@ -64,6 +74,7 @@ class HighLine end end + # At include time, it defines all basic builtin styles. def self.define_builtin_style_methods(base) HighLine::COLORS.each do |color| color = color.downcase @@ -94,6 +105,7 @@ class HighLine end end + # Adds color support to the base String class def self.colorize_strings ::String.send(:include, StringExtensions) end |