class NumRu::Units::Node

class Node

Node is a parent class for classes of parse tree node. This is not expected to be instanciated directly.

Public Class Methods

new(*args) click to toggle source
# File lib/numru/units.rb, line 475
def initialize(*args)
    raise "#{self.class} is virtual."
end

Public Instance Methods

deref() click to toggle source
# File lib/numru/units.rb, line 608
def deref
    self
end
divide(other) click to toggle source
# File lib/numru/units.rb, line 510
def divide(other)
    MulNode.new(self, PowNode.new(other, NumberNode.new(-1)))
end
flatten() click to toggle source
# File lib/numru/units.rb, line 556
def flatten
    flatten2
end
inspect() click to toggle source
# File lib/numru/units.rb, line 540
def inspect;  inspect2.gsub(/Units::/, '').gsub(/NumRu::/, '').gsub(/Node\[/, '[');  end
inspect2() click to toggle source
# File lib/numru/units.rb, line 538
def inspect2;  "#{self.class}[#{to_s}]";  end
mul(other) click to toggle source
# File lib/numru/units.rb, line 499
def mul(other)
    other = NumberNode.new(other) if Numeric === other
    MulNode.new(self, other)
end
pow(other) click to toggle source
# File lib/numru/units.rb, line 489
def pow(other)
    PowNode.new(self, other)
end
pow_eval(other) click to toggle source
# File lib/numru/units.rb, line 530
def pow_eval(other)
    pow(other)
end
reduce1() click to toggle source
# File lib/numru/units.rb, line 576
def reduce1
    self
end
reduce2() click to toggle source
# File lib/numru/units.rb, line 580
def reduce2
    trim
end
reduce3() click to toggle source
# File lib/numru/units.rb, line 584
def reduce3
    trim.flatten
end
reduce4() click to toggle source
# File lib/numru/units.rb, line 588
def reduce4
    # unalias(Hash.new).trim.flatten.sort
    foldnumber(nil).trim.flatten.sort
end
reduce5() click to toggle source
# File lib/numru/units.rb, line 593
def reduce5
    expand(Hash.new).trim.flatten.sort
end
ref() click to toggle source
# File lib/numru/units.rb, line 604
def ref
    NumberNode::ZERO
end
shift(other) click to toggle source
# File lib/numru/units.rb, line 520
def shift(other)
    ShiftNode.new(self, other)
end
sort() click to toggle source
# File lib/numru/units.rb, line 564
def sort
    raise "#{self.class}#sort is virtual: call after flatten"
end
to_s(*args) click to toggle source
# File lib/numru/units.rb, line 479
def to_s(*args)
    raise "#{self.class}#to_s is virtual."
end
trim() click to toggle source
# File lib/numru/units.rb, line 547
def trim
    trim2
end