Class: McBlocky::Location
- Inherits:
-
Struct
- Object
- Struct
- McBlocky::Location
- Defined in:
- lib/mcblocky/location.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
-
#z ⇒ Object
Returns the value of attribute z.
Instance Method Summary collapse
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x
2 3 4 |
# File 'lib/mcblocky/location.rb', line 2 def x @x end |
#y ⇒ Object
Returns the value of attribute y
2 3 4 |
# File 'lib/mcblocky/location.rb', line 2 def y @y end |
#z ⇒ Object
Returns the value of attribute z
2 3 4 |
# File 'lib/mcblocky/location.rb', line 2 def z @z end |
Instance Method Details
#+(other) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/mcblocky/location.rb', line 3 def +(other) if other.is_relative? Location.new(x + other.x, y + other.y, z + other.z) else RelativeLocation.new(x + other.x, y + other.y, z + other.z) end end |
#-(other) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/mcblocky/location.rb', line 11 def -(other) if other.is_relative? Location.new(x - other.x, y - other.y, z - other.z) else RelativeLocation.new(x - other.x, y - other.y, z - other.z) end end |
#is_relative? ⇒ Boolean
19 20 21 |
# File 'lib/mcblocky/location.rb', line 19 def is_relative? false end |