Class: Arrolio::LayoutSpec::Region

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

Overview

Named rectangle within a PageTemplate. The five standard regions are :body, :before (header), :after (footer), :start (left), :end (right). Pure geometry; runtime consumed state lives in Frame.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Region.



12
13
14
15
16
17
18
19
# File 'lib/arrolio/layout_spec/region.rb', line 12

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

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



10
11
12
# File 'lib/arrolio/layout_spec/region.rb', line 10

def height
  @height
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/arrolio/layout_spec/region.rb', line 10

def name
  @name
end

#widthObject (readonly)

Returns the value of attribute width.



10
11
12
# File 'lib/arrolio/layout_spec/region.rb', line 10

def width
  @width
end

#xObject (readonly)

Returns the value of attribute x.



10
11
12
# File 'lib/arrolio/layout_spec/region.rb', line 10

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



10
11
12
# File 'lib/arrolio/layout_spec/region.rb', line 10

def y
  @y
end

Instance Method Details

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



25
26
27
28
29
# File 'lib/arrolio/layout_spec/region.rb', line 25

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

#areaObject



21
22
23
# File 'lib/arrolio/layout_spec/region.rb', line 21

def area
  @width * @height
end

#hashObject



33
34
35
# File 'lib/arrolio/layout_spec/region.rb', line 33

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