Class: Quantity::Unit

Inherits:
Object
  • Object
show all
Defined in:
lib/quantity/unit.rb,
lib/quantity/unit/mass.rb,
lib/quantity/unit/time.rb,
lib/quantity/unit/length.rb,
lib/quantity/unit/current.rb,
lib/quantity/unit/substance.rb,
lib/quantity/unit/luminosity.rb,
lib/quantity/unit/temperature.rb

Instance Attribute Summary

Instance Method Summary

Constructor Details

- (Unit) initialize(name = nil)

A new instance of Unit

Parameters:

  • (String) name (defaults to: nil)


18
19
20
# File 'lib/quantity/unit.rb', line 18

def initialize(name = nil)
  @name = name || self.class.name.split(':').last.downcase
end

Instance Attribute Details

- (String) name (readonly) Also known as: to_s

Returns:

  • (String)


12
13
14
# File 'lib/quantity/unit.rb', line 12

def name
  @name
end

Instance Method Details

- (Symbol) to_sym

Returns:

  • (Symbol)


24
25
26
# File 'lib/quantity/unit.rb', line 24

def to_sym
  name.to_sym
end