struct Measure::Area

Included Modules

Defined in:

area.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(magnitude : Float64, unit : Measure::Area::Unit) #

Instantiate an Area instance with the given #magnitude and Unit.


[View source]

Instance Method Detail

def *(scalar : Number) : self #

Multiply by a scalar value

2.acres * 5
# => Measure::Area(@magnitude=10.0, @unit=Measure::Area::Unit::Acre)

[View source]
def *(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)

[View source]
def +(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)

[View source]
def -(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)

[View source]
def /(scalar : Number) : self #

Divide by a scalar value

10.acres / 2
# => Measure::Area(@magnitude=5.0, @unit=Measure::Area::Unit::Acre)

[View source]
def <=>(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

[View source]
def ==(other : self) #

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


[View source]
def magnitude : Float64 #

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


[View source]
def 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)

[View source]
def to_s(io : IO) : Nil #

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


[View source]
def total_square_meters : Float64 #

Returns the number of square meters represented by this Area instance


[View source]
def unit : Unit #

The unit used in measuring the area.


[View source]