class Cura::Offsets
The offsets of a component's drawing area.
Public Class Methods
new(attributes={})
click to toggle source
Calls superclass method
Cura::Attributes::HasAttributes::new
# File lib/cura/offsets.rb, line 13 def initialize(attributes={}) super raise ArgumentError, "component must be set" if @component.nil? end
Public Instance Methods
bottom()
click to toggle source
Get the bottom offset from the contents of a component from the bottom.
@return [Integer]
# File lib/cura/offsets.rb, line 48 def bottom attribute_sum(:bottom) end
height()
click to toggle source
Get the full height of offsets of a component.
@return [Integer]
# File lib/cura/offsets.rb, line 62 def height # top + bottom attribute_sum(:height) end
left()
click to toggle source
Get the left offset from the contents of a component from the left.
@return [Integer]
# File lib/cura/offsets.rb, line 55 def left attribute_sum(:left) end
right()
click to toggle source
Get the right offset from the contents of a component from the right.
@return [Integer]
# File lib/cura/offsets.rb, line 41 def right attribute_sum(:right) end
top()
click to toggle source
Get the top offset from the contents of a component from the top.
@return [Integer]
# File lib/cura/offsets.rb, line 34 def top attribute_sum(:top) end
width()
click to toggle source
Get the full width of offsets of a component.
@return [Integer]
# File lib/cura/offsets.rb, line 70 def width # left + right attribute_sum(:width) end
Protected Instance Methods
attribute_sum(method)
click to toggle source
# File lib/cura/offsets.rb, line 77 def attribute_sum(method) @component.padding.send(method) + @component.border.send(method) + @component.margin.send(method) end
validate_component(value)
click to toggle source
# File lib/cura/offsets.rb, line 81 def validate_component(value) raise TypeError, "value must be a Cura::Component::Base" unless value.is_a?(Cura::Component::Base) value end