Method: Unitwise::Unit#expression

Defined in:
lib/unitwise/unit.rb

#expression(mode = nil) ⇒ String

Build a string representation of this unit by it’s terms. (:primary_code, :names, :secondary_code).

Parameters:

  • mode (Symbol) (defaults to: nil)

    The mode to use to stringify the atoms

Returns:

  • (String)


44
45
46
47
48
49
50
# File 'lib/unitwise/unit.rb', line 44

def expression(mode=nil)
  if @expression && (mode.nil? || mode == self.mode)
    @expression
  else
    Expression.compose(terms, mode || self.mode)
  end
end