Sha256: 02f23c6a86c4e90d58ab6c4893fbe4229cd17df30ec2c6232f07affac8472b9b

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

# encoding: UTF-8

Measurement.define(:'km²') do |unit|
  unit.alias :km2, :'km^2', :'km*km', :'sq km', :'square kilometer', :'square kilometers'
  unit.convert_to(:ha) { |value| value * 100.0 }
  unit.convert_to(:a) { |value| value * 10_000.0 }
  unit.convert_to(:cm2) { |value| value * 10_000_000_000.0 }
end

Measurement.define(:ha) do |unit|
  unit.alias :hectare, :hectares
  unit.convert_to(:km2) { |value| value / 100.0 }
  unit.convert_to(:a) { |value| value * 100.0 }
  unit.convert_to(:cm2) { |value| value * 100_000_000.0 }
end

Measurement.define(:a) do |unit|
  unit.alias :are, :ares
  unit.convert_to(:km2) { |value| value / 10_000.0 }
  unit.convert_to(:ha) { |value| value / 100.0 }
  unit.convert_to(:cm2) { |value| value * 1_000_000.0 }
end

Measurement.define(:'cm²') do |unit|
  unit.alias :cm2, :'cm^2', :'cm*cm', :'sq cm', :'square centimeter', :'square centimeters'
  unit.convert_to(:km2) { |value| value / 10_000_000_000.0 }
  unit.convert_to(:ha) { |value| value / 100_000_000.0 }
  unit.convert_to(:a) { |value| value / 1_000_000.0 }
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruby-measurement-1.3.0 lib/ruby-measurement/definitions/metric/area.rb
ruby-measurement-1.2.3 lib/ruby-measurement/definitions/metric/area.rb
ruby-measurement-1.2.2 lib/ruby-measurement/definitions/metric/area.rb
ruby-measurement-1.2.1 lib/ruby-measurement/definitions/metric/area.rb
ruby-measurement-1.2.0 lib/ruby-measurement/definitions/metric/area.rb
ruby-measurement-1.1.0 lib/ruby-measurement/definitions/metric/area.rb
ruby-measurement-1.0.0 lib/ruby-measurement/definitions/metric/area.rb
ruby-measurement-0.0.1 lib/ruby-measurement/definitions/metric/area.rb