Measure::Area
Inherits Comparable < Struct < Value < Object
Constructors
Instantiate an Area instance with the given magnitude and Unit.
Instance methods
*(scalar : Number) : self
Multiply by a scalar value
2.acres * 5
# => Measure::Area(@magnitude=10.0, @unit=Measure::Area::Unit::Acre)
*(other : Length) : Volume
Multiply by a Length to get a Volume
1.square_meter * 1.meter
# => Measure::Volume(@magnitude=1.0, @unit=Measure::Volume::Unit::CubicMeter)
+(other : self) : self
Add two Areas of any units together, returning an instance using
self's Unit.
1.acre + 1.hectare
# => Measure::Area(@magnitude=3.47105, @unit=Measure::Area::Unit::Acre)
-(other : self) : self
Subtract an Area from self, returning an instance using self's
Unit.
2.hectares - 1.acre
# => Measure::Area(@magnitude=1.59514, @unit=Measure::Area::Unit::Hectare)
/(scalar : Number) : self
Divide by a scalar value
10.acres / 2
# => Measure::Area(@magnitude=5.0, @unit=Measure::Area::Unit::Acre)
<=>(other : self)
Returns -1 if self is less than other, 0 if they're equal, or 1
otherwise.
1.hectare <=> 1.acre # => 1
1.acre <=> 1.acre # => 0
1.acre <=> 1.hectare # => -1
1.acre < 1.hectare # => true
1.acre > 1.hectare # => false
==(other : self)
Returns true if self and other are close enough to each other to be
considered equivalent.
to(unit : Unit) : self
Convert this instance to the given Unit.
1.acre.to(:square_meters)
# => Measure::Area(@magnitude=4046.86, @unit=Measure::Area::Unit::SquareMeter)