Class: Mentor::TextToColor
- Inherits:
-
Object
- Object
- Mentor::TextToColor
- Includes:
- Colorize
- Defined in:
- lib/helpers/text_to_color.rb
Instance Method Summary collapse
- #color_pattern ⇒ Object
- #colored ⇒ Object
-
#initialize(full_text, text_to_color, output_type, match_pattern = nil) ⇒ TextToColor
constructor
A new instance of TextToColor.
Methods included from Colorize
Methods included from OutputHelper
#a_an, #and_sentence, #culprit_line, #home_to_tilde, #indent_lines, #lines_from_file, #or_sentence, #pluralize, #pluralize_words, #terminal_width, #valid_var_name
Constructor Details
#initialize(full_text, text_to_color, output_type, match_pattern = nil) ⇒ TextToColor
Returns a new instance of TextToColor.
7 8 9 10 11 12 |
# File 'lib/helpers/text_to_color.rb', line 7 def initialize(full_text, text_to_color, output_type, match_pattern = nil) @full_text = full_text @text_to_color = text_to_color @output_type = output_type @match_pattern = match_pattern end |
Instance Method Details
#color_pattern ⇒ Object
14 15 16 |
# File 'lib/helpers/text_to_color.rb', line 14 def color_pattern @full_text.gsub(@match_pattern, colored) end |
#colored ⇒ Object
18 19 20 21 |
# File 'lib/helpers/text_to_color.rb', line 18 def colored return @full_text unless text_to_color_exists? color_text end |