Class: Dieses::Geometry::Point::Mutable
- Inherits:
-
Dieses::Geometry::Point
- Object
- Dieses::Geometry::Point
- Dieses::Geometry::Point::Mutable
- Defined in:
- lib/dieses/geometry/point.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
writeonly
Sets the attribute x.
-
#y ⇒ Object
writeonly
Sets the attribute y.
Attributes inherited from Dieses::Geometry::Point
Class Method Summary collapse
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(x, y) ⇒ Mutable
constructor
rubocop:disable Lint/MissingSuper.
- #translate!(x: nil, y: nil) ⇒ Object
Methods inherited from Dieses::Geometry::Point
#<=>, #approx, call, #distance, distance, #eql?, origin, #to_a, #to_h, #to_s, #translate
Constructor Details
#initialize(x, y) ⇒ Mutable
rubocop:disable Lint/MissingSuper
77 78 79 |
# File 'lib/dieses/geometry/point.rb', line 77 def initialize(x, y) # rubocop:disable Lint/MissingSuper @x, @y = x.to_f, y.to_f end |
Instance Attribute Details
#x=(value) ⇒ Object (writeonly)
Sets the attribute x
75 76 77 |
# File 'lib/dieses/geometry/point.rb', line 75 def x=(value) @x = value end |
#y=(value) ⇒ Object (writeonly)
Sets the attribute y
75 76 77 |
# File 'lib/dieses/geometry/point.rb', line 75 def y=(value) @y = value end |
Class Method Details
Instance Method Details
#hash ⇒ Object
81 82 83 |
# File 'lib/dieses/geometry/point.rb', line 81 def hash (@hash ||= self.class.hash) ^ to_a.hash end |
#translate!(x: nil, y: nil) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/dieses/geometry/point.rb', line 85 def translate!(x: nil, y: nil) tap do self.x += (x || 0) self.y += (y || 0) end end |