Class: CfSim::Point
- Inherits:
-
Object
- Object
- CfSim::Point
- Defined in:
- lib/cf_sim/point.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name, x, y) ⇒ Point
constructor
A new instance of Point.
- #to_s ⇒ Object
Constructor Details
#initialize(name, x, y) ⇒ Point
Returns a new instance of Point.
4 5 6 7 |
# File 'lib/cf_sim/point.rb', line 4 def initialize(name, x, y) @name = name @x, @y = x, y end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/cf_sim/point.rb', line 2 def name @name end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
2 3 4 |
# File 'lib/cf_sim/point.rb', line 2 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
2 3 4 |
# File 'lib/cf_sim/point.rb', line 2 def y @y end |
Instance Method Details
#==(other) ⇒ Object
9 10 11 |
# File 'lib/cf_sim/point.rb', line 9 def ==(other) eql?(other) end |
#eql?(other) ⇒ Boolean
13 14 15 |
# File 'lib/cf_sim/point.rb', line 13 def eql?(other) @x == other.x && @y == other.y end |
#hash ⇒ Object
17 18 19 |
# File 'lib/cf_sim/point.rb', line 17 def hash @x + @y end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/cf_sim/point.rb', line 21 def to_s "#{name}(#{x}, #{y})" end |