Module: Cura::Attributes::HasSideAttributes
- Includes:
- HasAttributes
- Defined in:
- lib/cura/attributes/has_side_attributes.rb
Overview
Adds the ‘top`, `right`, `bottom`, `left`, `width`, and `height` attributes to objects.
Instance Method Summary collapse
-
#bottom ⇒ Integer
Get the bottom attribute.
-
#bottom=(value) ⇒ Integer
Set the bottom attribute.
-
#height ⇒ Integer
Get the total height of the attributes.
- #initialize(attributes = {}) ⇒ Object
-
#left ⇒ Integer
Get the left attribute.
-
#left=(value) ⇒ Integer
Set the left attribute.
-
#right ⇒ Integer
Get the right attribute.
-
#right=(value) ⇒ Integer
Set the right attribute.
-
#top ⇒ Integer
Get the top attribute.
-
#top=(value) ⇒ Integer
Set the top attribute.
-
#width ⇒ Integer
Get the total width of the attributes.
Methods included from HasAttributes
Instance Method Details
#bottom ⇒ Integer
Get the bottom attribute.
|
# File 'lib/cura/attributes/has_side_attributes.rb', line 35
|
#bottom=(value) ⇒ Integer
Set the bottom attribute.
46 |
# File 'lib/cura/attributes/has_side_attributes.rb', line 46 attribute(:bottom) { |value| validate_size_attribute(value) } |
#height ⇒ Integer
Get the total height of the attributes.
77 78 79 |
# File 'lib/cura/attributes/has_side_attributes.rb', line 77 def height @top + @bottom end |
#initialize(attributes = {}) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# 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 |
#left ⇒ Integer
Get the left attribute.
|
# File 'lib/cura/attributes/has_side_attributes.rb', line 48
|
#left=(value) ⇒ Integer
Set the left attribute.
59 |
# File 'lib/cura/attributes/has_side_attributes.rb', line 59 attribute(:left) { |value| validate_size_attribute(value) } |
#right ⇒ Integer
Get the right attribute.
|
# File 'lib/cura/attributes/has_side_attributes.rb', line 22
|
#right=(value) ⇒ Integer
Set the right attribute.
33 |
# File 'lib/cura/attributes/has_side_attributes.rb', line 33 attribute(:right) { |value| validate_size_attribute(value) } |
#top ⇒ Integer
Get the top attribute.
|
# File 'lib/cura/attributes/has_side_attributes.rb', line 9
|
#top=(value) ⇒ Integer
Set the top attribute.
20 |
# File 'lib/cura/attributes/has_side_attributes.rb', line 20 attribute(:top) { |value| validate_size_attribute(value) } |
#width ⇒ Integer
Get the total width of the attributes.
84 85 86 |
# File 'lib/cura/attributes/has_side_attributes.rb', line 84 def width @left + @right end |