struct

Measure::Area

Inherits Comparable < Struct < Value < Object

Constructors

new(magnitude : Float64, unit : Measure::Area::Unit)

Instantiate an Area instance with the given magnitude and Unit.

Source

Instance methods

*(scalar : Number) : self

Multiply by a scalar value

2.acres * 5
# => Measure::Area(@magnitude=10.0, @unit=Measure::Area::Unit::Acre)
Source
*(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)
Source
+(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)
Source
-(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)
Source
/(scalar : Number) : self

Divide by a scalar value

10.acres / 2
# => Measure::Area(@magnitude=5.0, @unit=Measure::Area::Unit::Acre)
Source
<=>(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
Source
==(other : self)

Returns true if self and other are close enough to each other to be considered equivalent.

Source
magnitude

The numeric part of the measurement — the 1 in 1.square_meter.

Source
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)
Source
to_s(io : IO) : Nil

Output a human-readable representation of this Area to the given IO.

Source
total_square_meters

Returns the number of square meters represented by this Area instance

Source
unit

The unit used in measuring the area.

Source

Nested types