Class: Vedeu::Geometry
- Inherits:
-
Object
- Object
- Vedeu::Geometry
- Defined in:
- lib/vedeu/models/geometry.rb
Instance Method Summary collapse
- #attributes ⇒ Object
- #bottom ⇒ Object
- #centred ⇒ Object
- #east(value = 1) ⇒ Object
- #height ⇒ Object
-
#initialize(attributes = {}) ⇒ Geometry
constructor
A new instance of Geometry.
- #left ⇒ Object
- #north(value = 1) ⇒ Object
- #origin(index = 0, &block) ⇒ Object
- #right ⇒ Object
- #south(value = 1) ⇒ Object
- #top ⇒ Object
- #west(value = 1) ⇒ Object
- #width ⇒ Object
- #x ⇒ Object
- #y ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Geometry
3 4 5 |
# File 'lib/vedeu/models/geometry.rb', line 3 def initialize(attributes = {}) @attributes = attributes end |
Instance Method Details
#attributes ⇒ Object
7 8 9 |
# File 'lib/vedeu/models/geometry.rb', line 7 def attributes defaults.merge!(@attributes) end |
#bottom ⇒ Object
59 60 61 |
# File 'lib/vedeu/models/geometry.rb', line 59 def bottom top + height end |
#centred ⇒ Object
27 28 29 |
# File 'lib/vedeu/models/geometry.rb', line 27 def centred @centred ||= attributes[:centred] end |
#east(value = 1) ⇒ Object
71 72 73 |
# File 'lib/vedeu/models/geometry.rb', line 71 def east(value = 1) right + value end |
#height ⇒ Object
23 24 25 |
# File 'lib/vedeu/models/geometry.rb', line 23 def height @height ||= attributes[:height] end |
#left ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/vedeu/models/geometry.rb', line 47 def left if centred centre_x - (width / 2) else x end end |
#north(value = 1) ⇒ Object
43 44 45 |
# File 'lib/vedeu/models/geometry.rb', line 43 def north(value = 1) top - value end |
#origin(index = 0, &block) ⇒ Object
31 32 33 |
# File 'lib/vedeu/models/geometry.rb', line 31 def origin(index = 0, &block) Esc.set_position(virtual_y[index], left, &block) end |
#right ⇒ Object
67 68 69 |
# File 'lib/vedeu/models/geometry.rb', line 67 def right left + width end |
#south(value = 1) ⇒ Object
63 64 65 |
# File 'lib/vedeu/models/geometry.rb', line 63 def south(value = 1) bottom + value end |
#top ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/vedeu/models/geometry.rb', line 35 def top if centred centre_y - (height / 2) else y end end |
#west(value = 1) ⇒ Object
55 56 57 |
# File 'lib/vedeu/models/geometry.rb', line 55 def west(value = 1) left - value end |
#width ⇒ Object
19 20 21 |
# File 'lib/vedeu/models/geometry.rb', line 19 def width @width ||= attributes[:width] end |
#x ⇒ Object
15 16 17 |
# File 'lib/vedeu/models/geometry.rb', line 15 def x @x ||= attributes[:x] end |
#y ⇒ Object
11 12 13 |
# File 'lib/vedeu/models/geometry.rb', line 11 def y @y ||= attributes[:y] end |