Module: Size
- Included in:
- Dimensions
- Defined in:
- tomes/spells/geometry/size.rb
Overview
A module for dealing with an object’s height (occasionally called “length”) and width. It is recommended you use #width and #height instead of #w or #h.
Instance Attribute Summary collapse
-
#height ⇒ Object
(also: #h)
The object’s length along the Y-axis.
-
#width ⇒ Object
(also: #w)
The object’s length along the X-axis.
Instance Method Summary collapse
-
#adjust_size(size_offset) ⇒ Void
(also: #grow)
Adds the size_offset[0, 1] to the width and height respectively.
-
#size ⇒ Array<Integer, Integer>
(also: #proportions)
Returns an array containing the object’s width and height attributes.
-
#size=(new_size) ⇒ Void
Sets the width and height.
Instance Attribute Details
#height ⇒ Object Also known as: h
The object’s length along the Y-axis.
11 |
# File 'tomes/spells/geometry/size.rb', line 11 attr_accessor :width, :height |
#width ⇒ Object Also known as: w
The object’s length along the X-axis.
11 12 13 |
# File 'tomes/spells/geometry/size.rb', line 11 def width @width end |
Instance Method Details
#adjust_size(size_offset) ⇒ Void Also known as: grow
Adds the size_offset[0, 1] to the width and height respectively.
26 27 28 29 |
# File 'tomes/spells/geometry/size.rb', line 26 def adjust_size(size_offset) self.width += size_offset[0] self.height += size_offset[1] end |
#size ⇒ Array<Integer, Integer> Also known as: proportions
Returns an array containing the object’s width and height attributes.
34 35 36 |
# File 'tomes/spells/geometry/size.rb', line 34 def size [width, height] end |
#size=(new_size) ⇒ Void
Sets the width and height.
19 20 21 |
# File 'tomes/spells/geometry/size.rb', line 19 def size=(new_size) self.width, self.height = new_size end |