Class: ColorfulReading::Colors
- Inherits:
-
Object
- Object
- ColorfulReading::Colors
- Defined in:
- lib/colorful_reading/colors.rb
Constant Summary collapse
- COLORS =
{ nn: :green, pr: :blue, vb: :red, jj: :yellow, rb: :blue, de: :magenta, in: :magenta, cc: :cyan, w: :cyan, }
Class Method Summary collapse
Class Method Details
.colorize(tagged_text) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/colorful_reading/colors.rb', line 17 def self.colorize(tagged_text) COLORS.each do |prefix, color| tagged_text.gsub!(/<#{prefix}\w*>(.+?)<\/#{prefix}\w*>/) do $1.colorize(color) end end tagged_text.gsub!(/<\w+>([^<]+)<\/\w+>/) { $1 } tagged_text end |