Class: Text

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

Direct Known Subclasses

Timer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(window, val, font, v, h, color = 0xffffff00) ⇒ Text

Returns a new instance of Text.



4
5
6
7
8
9
10
11
# File 'lib/text.rb', line 4

def initialize window, val, font, v, h, color = 0xffffff00
  self.window     = window
  self.value      = val
  self.font       = font
  self.color      = color
  self.vertical   = v
  self.horizontal = h
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



2
3
4
# File 'lib/text.rb', line 2

def color
  @color
end

#fontObject

Returns the value of attribute font.



2
3
4
# File 'lib/text.rb', line 2

def font
  @font
end

#horizontalObject

Returns the value of attribute horizontal.



2
3
4
# File 'lib/text.rb', line 2

def horizontal
  @horizontal
end

#valueObject

Returns the value of attribute value.



2
3
4
# File 'lib/text.rb', line 2

def value
  @value
end

#verticalObject

Returns the value of attribute vertical.



2
3
4
# File 'lib/text.rb', line 2

def vertical
  @vertical
end

#windowObject

Returns the value of attribute window.



2
3
4
# File 'lib/text.rb', line 2

def window
  @window
end

Instance Method Details

#drawObject



21
22
23
# File 'lib/text.rb', line 21

def draw
  font.draw value, horizon, vert, 1.0, 1.0, 1.0, color
end

#horizonObject



17
18
19
# File 'lib/text.rb', line 17

def horizon
  (horizontal == :left) ? 10 : window.width - font.text_width(value) - 10
end

#vertObject



13
14
15
# File 'lib/text.rb', line 13

def vert
  (vertical == :top)  ? 10 : window.height - font.height - 5
end