class Pulo::Unit

Attributes

abbreviation[R]
name[R]
plural[R]

Public Class Methods

new(name, plural, abbreviation) click to toggle source
# File lib/pulo/quantity/unit.rb, line 6
def initialize(name, plural, abbreviation)
  case plural
    when :s
      plural=name.to_s + 's'
    when :sf
      plural=name.to_s.sub(/(?<=.)_{1}/, 's_')
    else
      plural=plural.to_s
  end
  @name, @plural, @abbreviation=name, plural, abbreviation
end

Public Instance Methods

to_s() click to toggle source
# File lib/pulo/quantity/unit.rb, line 17
def to_s
  ret=abbreviation.ljust(12,' ') + name.to_s.ljust(30) + plural.ljust(30)
  if self.is_si?
    ret+='*10^' + self.scale.round(2).to_s.ljust(7,' ')
  else
    ret+=self.si_convert_factor.round(4).to_s + ' per ' + self.si_convert_unit.to_s
  end
  ret
end