Class: Measurement::Unit::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-measurement/unit.rb

Instance Method Summary collapse

Constructor Details

#initialize(unit_name, &block) ⇒ Builder

Returns a new instance of Builder.



72
73
74
75
# File 'lib/ruby-measurement/unit.rb', line 72

def initialize(unit_name, &block)
  @unit = Unit.new(unit_name)
  block.call(self) if block_given?
end

Instance Method Details

#alias(*args) ⇒ Object



77
78
79
# File 'lib/ruby-measurement/unit.rb', line 77

def alias(*args)
  @unit.add_alias(*args)
end

#convert_to(unit_name, &block) ⇒ Object



81
82
83
# File 'lib/ruby-measurement/unit.rb', line 81

def convert_to(unit_name, &block)
  @unit.add_conversion(unit_name, &block)
end

#to_unitObject



85
86
87
# File 'lib/ruby-measurement/unit.rb', line 85

def to_unit
  @unit
end