Module: Crayon
- Extended by:
- Crayon
- Includes:
- MethodParser, StringBuilder
- Included in:
- Crayon, CrayonString
- Defined in:
- lib/crayon.rb,
lib/crayon/version.rb,
lib/crayon/method_parser.rb,
lib/crayon/string_builder.rb
Defined Under Namespace
Modules: MethodParser, StringBuilder
Constant Summary collapse
- COLORS =
{ "black" => 0, "red" => 1, "green" => 2, "yellow" => 3, "blue" => 4, "magenta" => 5, "cyan" => 6, "white" => 7 }
- FORMATS =
{ "bold" => 1, "underline" => 4 }
- TERMINATION_STRING =
"\e[0m"- VERSION =
"1.2.0"
Class Attribute Summary collapse
-
.background ⇒ Object
Returns the value of attribute background.
-
.color ⇒ Object
Returns the value of attribute color.
-
.foreground ⇒ Object
Returns the value of attribute foreground.
-
.formatting ⇒ Object
Returns the value of attribute formatting.
-
.method_name ⇒ Object
Returns the value of attribute method_name.
Instance Method Summary collapse
Methods included from StringBuilder
#background_string, #foreground_string, #formatting_string, #handle_color, #has_color?, #prepare_string
Methods included from MethodParser
#parse_background, #parse_foreground, #parse_formatting, #parse_method_name
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, string) ⇒ Object
17 18 19 20 21 |
# File 'lib/crayon.rb', line 17 def method_missing(method_name, string) @method_name = method_name parse_method_name CrayonString.new(prepare_string(string) || "") end |
Class Attribute Details
.background ⇒ Object
Returns the value of attribute background.
10 11 12 |
# File 'lib/crayon.rb', line 10 def background @background end |
.color ⇒ Object
Returns the value of attribute color.
10 11 12 |
# File 'lib/crayon.rb', line 10 def color @color end |
.foreground ⇒ Object
Returns the value of attribute foreground.
10 11 12 |
# File 'lib/crayon.rb', line 10 def foreground @foreground end |
.formatting ⇒ Object
Returns the value of attribute formatting.
10 11 12 |
# File 'lib/crayon.rb', line 10 def formatting @formatting end |
.method_name ⇒ Object
Returns the value of attribute method_name.
10 11 12 |
# File 'lib/crayon.rb', line 10 def method_name @method_name end |