Class: TextWidget
- Inherits:
-
Object
- Object
- TextWidget
- Defined in:
- lib/delve/widgets/text.rb
Instance Method Summary collapse
- #draw(display) ⇒ Object
-
#initialize(x, y, text) ⇒ TextWidget
constructor
A new instance of TextWidget.
Constructor Details
#initialize(x, y, text) ⇒ TextWidget
Returns a new instance of TextWidget.
2 3 4 5 6 7 8 9 10 |
# File 'lib/delve/widgets/text.rb', line 2 def initialize(x, y, text) raise 'Cannot initialize text widget when x is nil' unless x raise 'Cannot initialize text widget when y is nil' unless y raise 'Cannot initialize text widget when text is nil' unless text @x = x @y = y @text = text end |
Instance Method Details
#draw(display) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/delve/widgets/text.rb', line 12 def draw(display) raise 'Cannot draw text when display is nil' unless display x = determine_x(display) y = determine_y(display) @text.each_char do |c| display.draw x, y, c x += 1 end end |