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.
7 8 9 |
# File 'lib/map/point.rb', line 7 def initialize(x = 0, y = 0, z = 0) @x, @y, @z = x, y, z end |
Instance Attribute Details
#x ⇒ Object
Attributes access
12 13 14 |
# File 'lib/map/point.rb', line 12 def x @x end |
#y ⇒ Object
Attributes access
12 13 14 |
# File 'lib/map/point.rb', line 12 def y @y end |
#z ⇒ Object
Attributes access
12 13 14 |
# File 'lib/map/point.rb', line 12 def z @z end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Redefinition of equal operator
15 16 17 |
# File 'lib/map/point.rb', line 15 def ==(other) (self.class ==other.class) && (self.state == other.state) end |
#hash ⇒ Object
It allows to use Point as a hash key
23 24 25 |
# File 'lib/map/point.rb', line 23 def hash state.hash end |
#to_s ⇒ Object
To string
28 29 30 |
# File 'lib/map/point.rb', line 28 def to_s "(#{@x},#{@y},#{@z})" end |