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
Returns a new instance of Data.
11 12 13 14 15 |
# File 'lib/graph_drawer/data.rb', line 11 def initialize(item, value) @item = item @value = value @level = nil end |
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
7 8 9 |
# File 'lib/graph_drawer/data.rb', line 7 def item @item end |
#level ⇒ Object
Returns the value of attribute level.
9 10 11 |
# File 'lib/graph_drawer/data.rb', line 9 def level @level end |
#value ⇒ Object
Returns the value of attribute value.
8 9 10 |
# File 'lib/graph_drawer/data.rb', line 8 def value @value end |
Instance Method Details
#to_s ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/graph_drawer/data.rb', line 17 def to_s color = case @level when 1 :green when 2 :cyan when 3 :blue end if @value.zero? draw_str = "#{@item}|" else = ' ' * (@value - @value.to_s.size) data_label = @value.to_s.color(:black) draw_str = "#{@item}|#{( + data_label).bg_color(color)}" end draw_str end |