Class: Geometry::Size
Overview
Constant Summary
Constants inherited from Vector
Vector::X, Vector::Y, Vector::Z
Instance Attribute Summary collapse
-
#x ⇒ Number
readonly
X-component (width).
-
#y ⇒ Number
readonly
Y-component (height).
-
#z ⇒ Number
readonly
Z-component (depth).
Class Method Summary collapse
-
.[](*array) ⇒ Size
Allow vector-style initialization, but override to support copy-init from Vector, Point or another Size.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Allow comparison with an Array, otherwise do the normal thing.
-
#depth ⇒ Number
The size along the Z axis.
-
#height ⇒ Number
The size along the Y axis.
- #inspect ⇒ Object
- #to_s ⇒ Object
-
#width ⇒ Number
The size along the X axis.
Methods inherited from Vector
Instance Attribute Details
#x ⇒ Number (readonly)
Returns X-component (width).
61 62 63 |
# File 'lib/geometry/size.rb', line 61 def x @x end |
#y ⇒ Number (readonly)
Returns Y-component (height).
66 67 68 |
# File 'lib/geometry/size.rb', line 66 def y @y end |
#z ⇒ Number (readonly)
Returns Z-component (depth).
71 72 73 |
# File 'lib/geometry/size.rb', line 71 def z @z end |
Class Method Details
.[](x, y, z, ...) ⇒ Size .[](Point) ⇒ Size .[](Size) ⇒ Size .[](Vector) ⇒ Size
Allow vector-style initialization, but override to support copy-init from Vector, Point or another Size
27 28 29 30 |
# File 'lib/geometry/size.rb', line 27 def self.[](*array) array = array[0].to_a unless array[0].is_a?(Numeric) super *array end |
Instance Method Details
#==(other) ⇒ Object
Allow comparison with an Array, otherwise do the normal thing
33 34 35 36 |
# File 'lib/geometry/size.rb', line 33 def ==(other) return @elements == other if other.is_a?(Array) super other end |
#depth ⇒ Number
Returns The size along the Z axis.
46 47 48 |
# File 'lib/geometry/size.rb', line 46 def depth z end |
#height ⇒ Number
Returns The size along the Y axis.
51 52 53 |
# File 'lib/geometry/size.rb', line 51 def height y end |
#inspect ⇒ Object
38 39 40 |
# File 'lib/geometry/size.rb', line 38 def inspect 'Size' + @elements.inspect end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/geometry/size.rb', line 41 def to_s 'Size' + @elements.to_s end |
#width ⇒ Number
Returns The size along the X axis.
56 57 58 |
# File 'lib/geometry/size.rb', line 56 def width x end |