Sha256: bb6fa4e4e30f0050241324706d8078f73b641db56f177c973ef41d67ab39aa3a

Contents?: true

Size: 929 Bytes

Versions: 20

Compression:

Stored size: 929 Bytes

Contents

module Unitwise::Standard
  class DerivedUnit < Base

    def self.remote_key
      "unit"
    end

    def self.local_key
      "derived_unit"
    end

    def property
      attributes["property"].to_s
    end

    def scale
      Scale.new(attributes["value"]) unless special?
    end

    def function
      Function.new(attributes["value"]) if special?
    end

    def classification
      attributes["@class"]
    end

    def metric?
      attributes["@isMetric"] == 'yes'
    end

    def special?
      attributes["@isSpecial"] == 'yes'
    end

    def arbitrary?
      attributes["@isArbitrary"] == 'yes'
    end

    def to_hash
      hash = super()
      hash[:scale] = (special? ? function.to_hash : scale.to_hash)
      hash.merge({:classification => classification,
                  :property => property, :metric => metric?,
                  :special => special?, :arbitrary => arbitrary?})
    end

  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
unitwise-2.3.0 lib/unitwise/standard/derived_unit.rb
unitwise-2.2.0 lib/unitwise/standard/derived_unit.rb
unitwise-2.1.0 lib/unitwise/standard/derived_unit.rb
unitwise-2.0.0 lib/unitwise/standard/derived_unit.rb
unitwise-1.1.0 lib/unitwise/standard/derived_unit.rb
unitwise-193-1.0.4 lib/unitwise/standard/derived_unit.rb
unitwise-1.0.4 lib/unitwise/standard/derived_unit.rb
unitwise-1.0.3 lib/unitwise/standard/derived_unit.rb
unitwise-1.0.2 lib/unitwise/standard/derived_unit.rb
unitwise-1.0.1 lib/unitwise/standard/derived_unit.rb
unitwise-1.0.0 lib/unitwise/standard/derived_unit.rb
unitwise-0.10.0 lib/unitwise/standard/derived_unit.rb
unitwise-0.9.1 lib/unitwise/standard/derived_unit.rb
unitwise-0.9.0 lib/unitwise/standard/derived_unit.rb
unitwise-0.8.1 lib/unitwise/standard/derived_unit.rb
unitwise-0.8.0 lib/unitwise/standard/derived_unit.rb
unitwise-0.7.1 lib/unitwise/standard/derived_unit.rb
unitwise-0.7.0 lib/unitwise/standard/derived_unit.rb
unitwise-0.6.2 lib/unitwise/standard/derived_unit.rb
unitwise-0.6.1 lib/unitwise/standard/derived_unit.rb