In Files

Included Modules

Files

MathViz::Measured

Something (i.e. MathViz::Term) which has MathViz::Units.

Public Instance Methods

per() click to toggle source

Statefull toggle numerator/denominator of unit assignment; e.g. m/s = .m.per.s

# File lib/mathviz.rb, line 268
def per
  @unit_sign ||= 1
  @unit_sign *= -1
  self
end
to_value() click to toggle source

api method for unwrapping terms

# File lib/mathviz.rb, line 280
def to_value
  to_f
end
unit(x) click to toggle source

Add the named unit to our units and return self. See also MathViz::Units::Class#new_units

# File lib/mathviz.rb, line 256
def unit(x)
  @unit ||= MathViz::Unit.new
  @unit_sign ||= 1
  if (@unit_sign > 0)
    @unit *= MathViz::Unit.new(x)
  else
    @unit /= MathViz::Unit.new(x)
  end
  self
end
units() click to toggle source

attr_reader

# File lib/mathviz.rb, line 275
def units
  @unit || MathViz::Unit.new
end
with_units() click to toggle source

Return a string representation of the units portion, with space if applicable

# File lib/mathviz.rb, line 246
def with_units
  u = units.to_s
  if (u.empty?)
    u
  else
    ' ' + u
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.