Class: Emf::Model::Geometry::PointF

Inherits:
Object
  • Object
show all
Defined in:
lib/emf/model/geometry/point_f.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x:, y:) ⇒ PointF

Returns a new instance of PointF.



7
8
9
10
# File 'lib/emf/model/geometry/point_f.rb', line 7

def initialize(x:, y:)
  @x = x.to_f
  @y = y.to_f
end

Instance Attribute Details

#xObject (readonly)

Returns the value of attribute x.



12
13
14
# File 'lib/emf/model/geometry/point_f.rb', line 12

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



12
13
14
# File 'lib/emf/model/geometry/point_f.rb', line 12

def y
  @y
end

Class Method Details

.from_wire(wire) ⇒ Object



14
15
16
# File 'lib/emf/model/geometry/point_f.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?



22
23
24
# File 'lib/emf/model/geometry/point_f.rb', line 22

def ==(other)
  other.is_a?(self.class) && x == other.x && y == other.y
end

#hashObject



27
28
29
# File 'lib/emf/model/geometry/point_f.rb', line 27

def hash
  [self.class, x, y].hash
end

#to_wireObject



18
19
20
# File 'lib/emf/model/geometry/point_f.rb', line 18

def to_wire
  Binary::Types::PointD.new(x: x, y: y)
end