Class: KeyValueWidget
- Inherits:
-
Object
- Object
- KeyValueWidget
- Defined in:
- lib/delve/widgets/key_value.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #draw(display) ⇒ Object
-
#initialize(x, y, label, value) ⇒ KeyValueWidget
constructor
A new instance of KeyValueWidget.
Constructor Details
#initialize(x, y, label, value) ⇒ KeyValueWidget
Returns a new instance of KeyValueWidget.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/delve/widgets/key_value.rb', line 4 def initialize(x, y, label, value) raise 'Cannot initialize key value widget when x is nil' unless x raise 'Cannot initialize key value widget when y is nil' unless y raise 'Cannot initialize key value widget when label is nil' unless label raise 'Cannot initialize key value widget when value is nil' unless value @x = x @y = y @label = label @value = value end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
2 3 4 |
# File 'lib/delve/widgets/key_value.rb', line 2 def value @value end |
Instance Method Details
#draw(display) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/delve/widgets/key_value.rb', line 16 def draw(display) raise 'Cannot draw text when display is nil' unless display x = @x @label.each_char do |c| display.draw x, @y, c x += 1 end display.draw x, @y, ':' x += 1 display.draw x, @y, ' ' x += 1 @value.each_char do |c| display.draw x, @y, c x += 1 end end |