Class: ChristmasTree::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/christmas_tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_pairObject

Returns the value of attribute color_pair.



27
28
29
# File 'lib/christmas_tree.rb', line 27

def color_pair
  @color_pair
end

#contentObject

Returns the value of attribute content.



27
28
29
# File 'lib/christmas_tree.rb', line 27

def content
  @content
end

#font_weightObject

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

#lengthObject



34
35
36
# File 'lib/christmas_tree.rb', line 34

def length
  @content.length
end