Class: ChristmasTree::Token
- Inherits:
-
Object
- Object
- ChristmasTree::Token
- Defined in:
- lib/christmas_tree.rb
Instance Attribute Summary collapse
-
#color_pair ⇒ Object
Returns the value of attribute color_pair.
-
#content ⇒ Object
Returns the value of attribute content.
-
#font_weight ⇒ Object
Returns the value of attribute font_weight.
Instance Method Summary collapse
- #draw(&block) ⇒ Object
-
#initialize(content, color_pair = nil, font_weight = nil) ⇒ Token
constructor
A new instance of Token.
- #length ⇒ Object
Constructor Details
#initialize(content, color_pair = nil, font_weight = nil) ⇒ Token
Returns a new instance of Token.
28 29 30 31 32 |
# File 'lib/christmas_tree.rb', line 28 def initialize(content, color_pair = nil, font_weight = nil) @content = content @font_weight = font_weight || :normal @color_pair = color_pair || :white end |
Instance Attribute Details
#color_pair ⇒ Object
Returns the value of attribute color_pair.
27 28 29 |
# File 'lib/christmas_tree.rb', line 27 def color_pair @color_pair end |
#content ⇒ Object
Returns the value of attribute content.
27 28 29 |
# File 'lib/christmas_tree.rb', line 27 def content @content end |
#font_weight ⇒ Object
Returns the value of attribute font_weight.
27 28 29 |
# File 'lib/christmas_tree.rb', line 27 def font_weight @font_weight end |
Instance Method Details
#draw(&block) ⇒ Object
38 39 40 41 42 |
# File 'lib/christmas_tree.rb', line 38 def draw(&block) Curses.attron(COLORS_MAP[@color_pair] | FONT_WEIGHT_MAP[@font_weight] ){ yield @content } end |
#length ⇒ Object
34 35 36 |
# File 'lib/christmas_tree.rb', line 34 def length @content.length end |