Class: Cura::Offsets
- Inherits:
-
Object
- Object
- Cura::Offsets
- Defined in:
- lib/cura/offsets.rb
Overview
The offsets of a component’s drawing area.
Instance Method Summary collapse
-
#bottom ⇒ Integer
Get the bottom offset from the contents of a component from the bottom.
-
#component ⇒ Component
Get the component to calculate offsets for.
-
#component=(value) ⇒ Component
Set the component to calculate offsets for.
-
#height ⇒ Integer
Get the full height of offsets of a component.
-
#initialize(attributes = {}) ⇒ Offsets
constructor
A new instance of Offsets.
-
#left ⇒ Integer
Get the left offset from the contents of a component from the left.
-
#right ⇒ Integer
Get the right offset from the contents of a component from the right.
-
#top ⇒ Integer
Get the top offset from the contents of a component from the top.
-
#width ⇒ Integer
Get the full width of offsets of a component.
Methods included from Attributes::HasAttributes
Constructor Details
#initialize(attributes = {}) ⇒ Offsets
Returns a new instance of Offsets.
15 16 17 18 19 |
# File 'lib/cura/offsets.rb', line 15 def initialize(attributes={}) super raise ArgumentError, "component must be set" if @component.nil? end |
Instance Method Details
#bottom ⇒ Integer
Get the bottom offset from the contents of a component from the bottom.
50 51 52 |
# File 'lib/cura/offsets.rb', line 50 def bottom attribute_sum(:bottom) end |
#component ⇒ Component
Get the component to calculate offsets for.
|
# File 'lib/cura/offsets.rb', line 21
|
#component=(value) ⇒ Component
Set the component to calculate offsets for.
31 |
# File 'lib/cura/offsets.rb', line 31 attribute(:component) { |value| validate_component(value) } |
#height ⇒ Integer
Get the full height of offsets of a component.
64 65 66 67 |
# File 'lib/cura/offsets.rb', line 64 def height # top + bottom attribute_sum(:height) end |
#left ⇒ Integer
Get the left offset from the contents of a component from the left.
57 58 59 |
# File 'lib/cura/offsets.rb', line 57 def left attribute_sum(:left) end |
#right ⇒ Integer
Get the right offset from the contents of a component from the right.
43 44 45 |
# File 'lib/cura/offsets.rb', line 43 def right attribute_sum(:right) end |
#top ⇒ Integer
Get the top offset from the contents of a component from the top.
36 37 38 |
# File 'lib/cura/offsets.rb', line 36 def top attribute_sum(:top) end |
#width ⇒ Integer
Get the full width of offsets of a component.
72 73 74 75 |
# File 'lib/cura/offsets.rb', line 72 def width # left + right attribute_sum(:width) end |