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



209
210
211
# File 'lib/mathviz.rb', line 209

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



200
201
202
203
204
205
206
# File 'lib/mathviz.rb', line 200

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