Class: Emf::Model::Geometry::Point
- Inherits:
-
Object
- Object
- Emf::Model::Geometry::Point
- Defined in:
- lib/emf/model/geometry/point.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(x:, y:) ⇒ Point
constructor
A new instance of Point.
- #inspect ⇒ Object
- #to_wire ⇒ Object
- #translate(dx, dy) ⇒ Object
Constructor Details
#initialize(x:, y:) ⇒ Point
Returns a new instance of Point.
7 8 9 10 |
# File 'lib/emf/model/geometry/point.rb', line 7 def initialize(x:, y:) @x = x @y = y end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
12 13 14 |
# File 'lib/emf/model/geometry/point.rb', line 12 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
12 13 14 |
# File 'lib/emf/model/geometry/point.rb', line 12 def y @y end |
Class Method Details
.from_wire(wire) ⇒ Object
14 15 16 |
# File 'lib/emf/model/geometry/point.rb', line 14 def self.from_wire(wire) new(x: wire.x, y: wire.y) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
26 27 28 |
# File 'lib/emf/model/geometry/point.rb', line 26 def ==(other) other.is_a?(self.class) && x == other.x && y == other.y end |
#hash ⇒ Object
31 32 33 |
# File 'lib/emf/model/geometry/point.rb', line 31 def hash [self.class, x, y].hash end |
#inspect ⇒ Object
35 36 37 |
# File 'lib/emf/model/geometry/point.rb', line 35 def inspect "#<#{self.class.name} x=#{x} y=#{y}>" end |
#to_wire ⇒ Object
18 19 20 |
# File 'lib/emf/model/geometry/point.rb', line 18 def to_wire Binary::Types::PointL.new(x: x, y: y) end |
#translate(dx, dy) ⇒ Object
22 23 24 |
# File 'lib/emf/model/geometry/point.rb', line 22 def translate(dx, dy) self.class.new(x: x + dx, y: y + dy) end |