Class: MapPoint::Point
- Inherits:
-
Object
- Object
- MapPoint::Point
- Defined in:
- lib/map/point.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
Attributes access.
-
#y ⇒ Object
Attributes access.
-
#z ⇒ Object
Attributes access.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Redefinition of equal operator.
-
#hash ⇒ Object
It allows to use Point as a hash key.
-
#initialize(x = 0, y = 0, z = 0) ⇒ Point
constructor
A new instance of Point.
-
#to_s ⇒ Object
To string.
Constructor Details
#initialize(x = 0, y = 0, z = 0) ⇒ Point
Returns a new instance of Point.
5 6 7 |
# File 'lib/map/point.rb', line 5 def initialize(x = 0, y = 0, z = 0) @x, @y, @z = x, y, z end |
Instance Attribute Details
#x ⇒ Object
Attributes access
10 11 12 |
# File 'lib/map/point.rb', line 10 def x @x end |
#y ⇒ Object
Attributes access
10 11 12 |
# File 'lib/map/point.rb', line 10 def y @y end |
#z ⇒ Object
Attributes access
10 11 12 |
# File 'lib/map/point.rb', line 10 def z @z end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Redefinition of equal operator
13 14 15 |
# File 'lib/map/point.rb', line 13 def ==(other) (self.class ==other.class) && (self.state == other.state) end |
#hash ⇒ Object
It allows to use Point as a hash key
21 22 23 |
# File 'lib/map/point.rb', line 21 def hash state.hash end |
#to_s ⇒ Object
To string
26 27 28 |
# File 'lib/map/point.rb', line 26 def to_s "(#{@x},#{@y},#{@z})" end |