module Cura::Attributes::HasSideAttributes
Adds the `top`, `right`, `bottom`, `left`, `width`, and `height` attributes to objects.
Public Class Methods
new(attributes={})
click to toggle source
Calls superclass method
Cura::Attributes::HasAttributes::new
# File lib/cura/attributes/has_side_attributes.rb, line 61 def initialize(attributes={}) @top = 0 unless instance_variable_defined?(:@top) @right = 0 unless instance_variable_defined?(:@right) @bottom = 0 unless instance_variable_defined?(:@bottom) @left = 0 unless instance_variable_defined?(:@left) unless attributes.respond_to?(:to_hash) || attributes.respond_to?(:to_h) attributes = { top: attributes, right: attributes, bottom: attributes, left: attributes } # Set all side attributes to the argument given end super end
Public Instance Methods
height()
click to toggle source
Get the total height of the attributes.
@return [Integer]
# File lib/cura/attributes/has_side_attributes.rb, line 77 def height @top + @bottom end
width()
click to toggle source
Get the total width of the attributes.
@return [Integer]
# File lib/cura/attributes/has_side_attributes.rb, line 84 def width @left + @right end