Module: MathViz::Units::Class

Included in:
MathViz::Units
Defined in:
lib/mathviz.rb

Overview

Provides the new_units class method to all classes with units

Instance Method Summary collapse

Instance Method Details

#included(host) ⇒ Object

extend MathViz::Units::Class



155
156
157
# File 'lib/mathviz.rb', line 155

def included(host)
  host.extend(MathViz::Units::Class)
end

#new_units(*units) ⇒ Object

Define new units (instance methods) on module MathViz::Units (where they will be picked up by everything including the module) Defined methods are essentialy aliases for #unit(name); see MathViz::Measurable / MathViz::Measured



146
147
148
149
150
151
152
# File 'lib/mathviz.rb', line 146

def new_units(*units)
  units.each do |u|
    MathViz::Units.__send__ :define_method, u do
      unit(u)
    end
  end
end