Class: Zabbirc::RichTextFormatter
- Inherits:
-
Object
- Object
- Zabbirc::RichTextFormatter
- Defined in:
- lib/zabbirc/rich_text_formatter.rb
Constant Summary collapse
- DEFAULT_PALETTE =
Zabbirc::Palettes::Default
- COMMANDS =
C - color, B - bold, U - underlined, RST - reset all formatting
%w[C B U RST]
- COMMANDS_REGEXP =
Regexp.union(COMMANDS)
Instance Method Summary collapse
- #format(msg) ⇒ Object
-
#initialize(palette = DEFAULT_PALETTE) ⇒ RichTextFormatter
constructor
A new instance of RichTextFormatter.
Constructor Details
#initialize(palette = DEFAULT_PALETTE) ⇒ RichTextFormatter
Returns a new instance of RichTextFormatter.
9 10 11 |
# File 'lib/zabbirc/rich_text_formatter.rb', line 9 def initialize palette=DEFAULT_PALETTE @palette = palette.new end |
Instance Method Details
#format(msg) ⇒ Object
13 14 15 16 |
# File 'lib/zabbirc/rich_text_formatter.rb', line 13 def format msg tokens = tokenize msg @palette.format tokens end |