Module: MathViz::Measurable

Includes:
Units
Included in:
Numeric
Defined in:
lib/mathviz.rb

Overview

Something (i.e. Numeric) which does not have MathViz::Units, but can be turned into something which does (i.e., MathViz::Constant)

Instance Method Summary collapse

Methods included from Units::Class

#included, #new_units

Instance Method Details

#perObject

return term wrapping self with new units assigned to the denominator



227
228
229
# File 'lib/mathviz.rb', line 227

def per
  MathViz.default_term.new(self).per
end

#to_valueObject

api method for unwrapping terms



232
233
234
235
236
237
238
# File 'lib/mathviz.rb', line 232

def to_value
  if kind_of? Numeric
    to_f
  else
    self
  end
end

#unit(x) ⇒ Object

return term wrapping self with the specified units; see also MathViz::Units::Class#new_units



222
223
224
# File 'lib/mathviz.rb', line 222

def unit(x)
  MathViz.default_term.new(self).unit(x)
end