Class: Rubygoal::Coordinate
- Inherits:
-
Struct
- Object
- Struct
- Rubygoal::Coordinate
- Defined in:
- lib/rubygoal/coordinate.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x
4 5 6 |
# File 'lib/rubygoal/coordinate.rb', line 4 def x @x end |
#y ⇒ Object
Returns the value of attribute y
4 5 6 |
# File 'lib/rubygoal/coordinate.rb', line 4 def y @y end |
Instance Method Details
#add(coordinate) ⇒ Object
9 10 11 |
# File 'lib/rubygoal/coordinate.rb', line 9 def add(coordinate) Coordinate.new(x + coordinate.x, y + coordinate.y) end |
#distance(coordinate) ⇒ Object
5 6 7 |
# File 'lib/rubygoal/coordinate.rb', line 5 def distance(coordinate) Gosu.distance(x, y, coordinate.x, coordinate.y) end |
#to_s ⇒ Object
13 14 15 |
# File 'lib/rubygoal/coordinate.rb', line 13 def to_s "(#{x}, #{y})" end |