Class: Arrolio::Output::Region

Inherits:
Object
  • Object
show all
Defined in:
lib/arrolio/output/region.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, x:, y:, width:, height:, placed_boxes: []) ⇒ Region

Returns a new instance of Region.



8
9
10
11
12
13
14
15
16
# File 'lib/arrolio/output/region.rb', line 8

def initialize(name:, x:, y:, width:, height:, placed_boxes: [])
  @name = name.to_sym
  @x = x.to_f
  @y = y.to_f
  @width = width.to_f
  @height = height.to_f
  @placed_boxes = Array(placed_boxes).freeze
  freeze
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



6
7
8
# File 'lib/arrolio/output/region.rb', line 6

def height
  @height
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/arrolio/output/region.rb', line 6

def name
  @name
end

#placed_boxesObject (readonly)

Returns the value of attribute placed_boxes.



6
7
8
# File 'lib/arrolio/output/region.rb', line 6

def placed_boxes
  @placed_boxes
end

#widthObject (readonly)

Returns the value of attribute width.



6
7
8
# File 'lib/arrolio/output/region.rb', line 6

def width
  @width
end

#xObject (readonly)

Returns the value of attribute x.



6
7
8
# File 'lib/arrolio/output/region.rb', line 6

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



6
7
8
# File 'lib/arrolio/output/region.rb', line 6

def y
  @y
end

Instance Method Details

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



18
19
20
21
22
23
# File 'lib/arrolio/output/region.rb', line 18

def ==(other)
  other.is_a?(self.class) &&
    name == other.name && x == other.x && y == other.y &&
    width == other.width && height == other.height &&
    placed_boxes == other.placed_boxes
end

#hashObject



27
28
29
# File 'lib/arrolio/output/region.rb', line 27

def hash
  [self.class, name, x, y, width, height, placed_boxes].hash
end