class Euclidean::Size

An object representing the size of something.

Supports all of the familiar {Vector} methods as well as a few convenience methods (width, height and depth).

Usage

Constructor

size = Geometry::Size[x,y,z]

Attributes

x[R]
y[R]
z[R]

Public Class Methods

[](*array) click to toggle source

Allow vector-style initialization, but override to support copy-init from Vector, Point or another Size

@overload [](x,y,z,…) @overload [](Point) @overload [](Size) @overload [](Vector) @return [Size] A new {Size} object

Calls superclass method
# File lib/euclidean/size.rb, line 27
def self.[](*array)
  array = array[0].to_a unless array[0].is_a?(Numeric)
  super *array
end

Public Instance Methods

==(other) click to toggle source

Allow comparison with an Array, otherwise do the normal thing

Calls superclass method
# File lib/euclidean/size.rb, line 33
def ==(other)
  return @elements == other if other.is_a?(Array)
  super other
end
depth() click to toggle source

@return [Number] The size along the Z axis

# File lib/euclidean/size.rb, line 39
def depth
  z
end
height() click to toggle source

@return [Number] The size along the Y axis

# File lib/euclidean/size.rb, line 44
def height
  y
end
inspect() click to toggle source
# File lib/euclidean/size.rb, line 48
def inspect
  'Size' + @elements.inspect
end
to_s() click to toggle source
# File lib/euclidean/size.rb, line 52
def to_s
  'Size' + @elements.to_s
end
width() click to toggle source

@return [Number] The size along the X axis

# File lib/euclidean/size.rb, line 57
def width
  x
end