Class: Coordinates
- Inherits:
-
Vector2d
- Object
- Vector2d
- Coordinates
- Defined in:
- lib/fantasy/coordinates.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
writeonly
Sets the attribute x.
-
#y ⇒ Object
writeonly
Sets the attribute y.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#x=(value) ⇒ Object (writeonly)
Sets the attribute x
6 7 8 |
# File 'lib/fantasy/coordinates.rb', line 6 def x=(value) @x = value end |
#y=(value) ⇒ Object (writeonly)
Sets the attribute y
6 7 8 |
# File 'lib/fantasy/coordinates.rb', line 6 def y=(value) @y = value end |
Class Method Details
.down ⇒ Object
16 17 18 |
# File 'lib/fantasy/coordinates.rb', line 16 def self.down Coordinates.new(0, 1) end |
.left ⇒ Object
20 21 22 |
# File 'lib/fantasy/coordinates.rb', line 20 def self.left Coordinates.new(-1, 0) end |
.right ⇒ Object
24 25 26 |
# File 'lib/fantasy/coordinates.rb', line 24 def self.right Coordinates.new(1, 0) end |
.up ⇒ Object
12 13 14 |
# File 'lib/fantasy/coordinates.rb', line 12 def self.up Coordinates.new(0, -1) end |
.zero ⇒ Object
8 9 10 |
# File 'lib/fantasy/coordinates.rb', line 8 def self.zero Coordinates.new(0, 0) end |
Instance Method Details
#clone ⇒ Object
28 29 30 |
# File 'lib/fantasy/coordinates.rb', line 28 def clone Coordinates.new(@x, @y) end |
#zero? ⇒ Boolean
32 33 34 |
# File 'lib/fantasy/coordinates.rb', line 32 def zero? @x.zero? && @y.zero? end |