Class: GraphDrawer::Data
- Inherits:
-
Object
- Object
- GraphDrawer::Data
- Defined in:
- lib/graph_drawer/data.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
Returns the value of attribute item.
-
#level ⇒ Object
Returns the value of attribute level.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(item, value) ⇒ Data
constructor
A new instance of Data.
- #to_s ⇒ Object
Constructor Details
#initialize(item, value) ⇒ Data
9 10 11 12 13 |
# File 'lib/graph_drawer/data.rb', line 9 def initialize(item, value) @item = item @value = value @level = nil end |
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
5 6 7 |
# File 'lib/graph_drawer/data.rb', line 5 def item @item end |
#level ⇒ Object
Returns the value of attribute level.
7 8 9 |
# File 'lib/graph_drawer/data.rb', line 7 def level @level end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/graph_drawer/data.rb', line 6 def value @value end |
Instance Method Details
#to_s ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/graph_drawer/data.rb', line 15 def to_s color = case @level when 1 :green when 2 :cyan when 3 :blue end if @value.zero? draw_str = "#{@item}|" else = ' ' * (@value - 1) data_label = @value.to_s.color(:black) draw_str = "#{@item}|#{(bar + data_label).bg_color(color)}" end draw_str end |