Class: Arrolio::LayoutSpec::Region
- Inherits:
-
Object
- Object
- Arrolio::LayoutSpec::Region
- 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
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #area ⇒ Object
- #hash ⇒ Object
-
#initialize(name:, x:, y:, width:, height:) ⇒ Region
constructor
A new instance of Region.
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
#height ⇒ Object (readonly)
Returns the value of attribute height.
10 11 12 |
# File 'lib/arrolio/layout_spec/region.rb', line 10 def height @height end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/arrolio/layout_spec/region.rb', line 10 def name @name end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
10 11 12 |
# File 'lib/arrolio/layout_spec/region.rb', line 10 def width @width end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
10 11 12 |
# File 'lib/arrolio/layout_spec/region.rb', line 10 def x @x end |
#y ⇒ Object (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 |
#area ⇒ Object
21 22 23 |
# File 'lib/arrolio/layout_spec/region.rb', line 21 def area @width * @height end |
#hash ⇒ Object
33 34 35 |
# File 'lib/arrolio/layout_spec/region.rb', line 33 def hash [self.class, name, x, y, width, height].hash end |