struct
Measure::Area
- Measure::Area
- Struct
- Value
- Object
Included Modules
- Comparable(Measure::Area)
Defined in:
area.crConstructors
-
.new(magnitude : Float64, unit : Measure::Area::Unit)
Instantiate an
Areainstance with the given#magnitudeandUnit.
Instance Method Summary
-
#*(scalar : Number) : self
Multiply by a scalar value
- #*(other : Length) : Volume
- #+(other : self) : self
- #-(other : self) : self
-
#/(scalar : Number) : self
Divide by a scalar value
-
#<=>(other : self)
Returns
-1ifselfis less thanother,0if they're equal, or1otherwise. -
#==(other : self)
Returns
trueifselfandotherare close enough to each other to be considered equivalent. -
#magnitude : Float64
The numeric part of the measurement — the
1in1.square_meter. -
#to(unit : Unit) : self
Convert this instance to the given
Unit. -
#to_s(io : IO) : Nil
Output a human-readable representation of this
Areato the givenIO. -
#total_square_meters : Float64
Returns the number of square meters represented by this
Areainstance -
#unit : Unit
The unit used in measuring the area.
Constructor Detail
Instantiate an Area instance with the given #magnitude and Unit.
Instance Method Detail
Multiply by a scalar value
2.acres * 5
# => Measure::Area(@magnitude=10.0, @unit=Measure::Area::Unit::Acre)
Multiply by a Length to get a Volume
1.square_meter * 1.meter
# => Measure::Volume(@magnitude=1.0, @unit=Measure::Volume::Unit::CubicMeter)
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)
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)
Divide by a scalar value
10.acres / 2
# => Measure::Area(@magnitude=5.0, @unit=Measure::Area::Unit::Acre)
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
Returns true if self and other are close enough to each other to be
considered equivalent.
Convert this instance to the given Unit.
1.acre.to(:square_meters)
# => Measure::Area(@magnitude=4046.86, @unit=Measure::Area::Unit::SquareMeter)