Sha256: 4a5ad263ed68d2684762c33eb5bbdc673d635de6cc38a42842b215cb910b18ff
Contents?: true
Size: 885 Bytes
Versions: 3
Compression:
Stored size: 885 Bytes
Contents
module Unitwise class Scale attr_reader :value include Unitwise::Composable def initialize(value, unit) @value = value if unit.is_a?(Unit) @unit = unit.dup else @unit = Unit.new(unit.to_s) end end def dup self.class.new(value, unit) end def atoms unit.atoms end def terms unit.terms end def special? unit.special? end def functional(x=value, direction=1) unit.functional(x, direction) end def scalar value * unit.scalar end def unit @unit ||= Unit.new(@unit_code) end def root_terms unit.root_terms end def depth unit.depth + 1 end def terminal? depth <= 3 end def to_s "#{value} #{unit}" end def inspect "<#{self.class} #{to_s}>" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
unitwise-0.3.0 | lib/unitwise/scale.rb |
unitwise-0.2.2 | lib/unitwise/scale.rb |
unitwise-0.2.1 | lib/unitwise/scale.rb |