Class: Mentor::TextToColor

Inherits:
Object
  • Object
show all
Includes:
Colorize
Defined in:
lib/helpers/text_to_color.rb

Instance Method Summary collapse

Methods included from Colorize

#colorize, #colorize_section

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_patternObject



14
15
16
# File 'lib/helpers/text_to_color.rb', line 14

def color_pattern
  @full_text.gsub(@match_pattern, colored)
end

#coloredObject



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