Class: Emf::Model::Geometry::RectS

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left:, top:, right:, bottom:) ⇒ RectS

Returns a new instance of RectS.



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

def initialize(left:, top:, right:, bottom:)
  @left = left
  @top = top
  @right = right
  @bottom = bottom
end

Instance Attribute Details

#bottomObject (readonly)

Returns the value of attribute bottom.



14
15
16
# File 'lib/emf/model/geometry/rect_s.rb', line 14

def bottom
  @bottom
end

#leftObject (readonly)

Returns the value of attribute left.



14
15
16
# File 'lib/emf/model/geometry/rect_s.rb', line 14

def left
  @left
end

#rightObject (readonly)

Returns the value of attribute right.



14
15
16
# File 'lib/emf/model/geometry/rect_s.rb', line 14

def right
  @right
end

#topObject (readonly)

Returns the value of attribute top.



14
15
16
# File 'lib/emf/model/geometry/rect_s.rb', line 14

def top
  @top
end

Class Method Details

.from_wire(wire) ⇒ Object



16
17
18
# File 'lib/emf/model/geometry/rect_s.rb', line 16

def self.from_wire(wire)
  new(left: wire.left, top: wire.top, right: wire.right, bottom: wire.bottom)
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



36
37
38
39
40
# File 'lib/emf/model/geometry/rect_s.rb', line 36

def ==(other)
  other.is_a?(self.class) &&
    left == other.left && top == other.top &&
    right == other.right && bottom == other.bottom
end

#empty?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/emf/model/geometry/rect_s.rb', line 32

def empty?
  width <= 0 || height <= 0
end

#hashObject



43
44
45
# File 'lib/emf/model/geometry/rect_s.rb', line 43

def hash
  [self.class, left, top, right, bottom].hash
end

#heightObject



28
29
30
# File 'lib/emf/model/geometry/rect_s.rb', line 28

def height
  bottom - top
end

#to_wireObject



20
21
22
# File 'lib/emf/model/geometry/rect_s.rb', line 20

def to_wire
  Binary::Types::RectS.new(left: left, top: top, right: right, bottom: bottom)
end

#widthObject



24
25
26
# File 'lib/emf/model/geometry/rect_s.rb', line 24

def width
  right - left
end