Module: Location
- Included in:
- Dimensions, Mouse
- Defined in:
- tomes/spells/geometry/location.rb
Overview
A module for dealing with an object’s location in 2D space.
Instance Attribute Summary collapse
-
#x ⇒ Object
The X coordinate.
-
#y ⇒ Object
The Y coordinate.
Instance Method Summary collapse
-
#adjust_location(location_offset) ⇒ Void
(also: #move)
Adds the X and Y values (indices 0 and 1) to the X and Y attributes, respectively.
-
#location ⇒ Array<Integer, Integer>
(also: #point)
Returns an array of the object’s X and Y coordinates.
-
#location=(new_location) ⇒ Void
(also: #change_location)
Sets the X and Y attributes.
Instance Attribute Details
#x ⇒ Object
The X coordinate.
10 11 12 |
# File 'tomes/spells/geometry/location.rb', line 10 def x @x end |
#y ⇒ Object
The Y coordinate.
10 |
# File 'tomes/spells/geometry/location.rb', line 10 attr_accessor :x, :y |
Instance Method Details
#adjust_location(location_offset) ⇒ Void Also known as: move
Adds the X and Y values (indices 0 and 1) to the X and Y attributes, respectively.
23 24 25 26 |
# File 'tomes/spells/geometry/location.rb', line 23 def adjust_location(location_offset) self.x += location_offset[0] self.y += location_offset[1] end |
#location ⇒ Array<Integer, Integer> Also known as: point
Returns an array of the object’s X and Y coordinates.
31 32 33 |
# File 'tomes/spells/geometry/location.rb', line 31 def location [x, y] end |
#location=(new_location) ⇒ Void Also known as: change_location
Sets the X and Y attributes.
15 16 17 |
# File 'tomes/spells/geometry/location.rb', line 15 def location=(new_location) self.x, self.y = new_location end |