Class: Concolor::String
- Inherits:
-
Object
- Object
- Concolor::String
- Defined in:
- lib/concolor/string.rb
Overview
Extension module for String class
Instance Method Summary collapse
-
#initialize(str = '', options: []) ⇒ String
constructor
A new instance of String.
-
#to_s ⇒ String
(also: #inspect)
To string.
Constructor Details
#initialize(str = '', options: []) ⇒ String
Returns a new instance of String.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/concolor/string.rb', line 10 def initialize(str = '', options: []) @str = str parsed = () @color = ::Concolor::Mappers::COLORS[parsed[:colors].first] @bg_color = ::Concolor::Mappers::BG_COLORS[parsed[:bg_colors].first] @modes = parsed[:modes].map do |mode| Concolor::Mappers::MODES[mode] end end |
Instance Method Details
#to_s ⇒ String Also known as: inspect
To string
24 25 26 |
# File 'lib/concolor/string.rb', line 24 def to_s "\033[#{style}m#{@str}\033[0m" end |