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 39
|
#bottom=(value) ⇒ Integer
Set the bottom attribute.
50 |
# File 'lib/cura/attributes/has_side_attributes.rb', line 50 attribute(:bottom) { |value| validate_size_attribute(value) } |
#height ⇒ Integer
Get the total height of the attributes.
81 82 83 |
# File 'lib/cura/attributes/has_side_attributes.rb', line 81 def height @top + @bottom end |
#initialize(attributes = {}) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cura/attributes/has_side_attributes.rb', line 65 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 52
|
#left=(value) ⇒ Integer
Set the left attribute.
63 |
# File 'lib/cura/attributes/has_side_attributes.rb', line 63 attribute(:left) { |value| validate_size_attribute(value) } |
#right ⇒ Integer
Get the right attribute.
|
# File 'lib/cura/attributes/has_side_attributes.rb', line 26
|
#right=(value) ⇒ Integer
Set the right attribute.
37 |
# File 'lib/cura/attributes/has_side_attributes.rb', line 37 attribute(:right) { |value| validate_size_attribute(value) } |
#top ⇒ Integer
Get the top attribute.
|
# File 'lib/cura/attributes/has_side_attributes.rb', line 13
|
#top=(value) ⇒ Integer
Set the top attribute.
24 |
# File 'lib/cura/attributes/has_side_attributes.rb', line 24 attribute(:top) { |value| validate_size_attribute(value) } |
#width ⇒ Integer
Get the total width of the attributes.
88 89 90 |
# File 'lib/cura/attributes/has_side_attributes.rb', line 88 def width @left + @right end |