Sha256: 1de1d9571251e008f1eba0f0cda4200fa51d35eb15ad5e5e56143e020a8478b0
Contents?: true
Size: 761 Bytes
Versions: 3
Compression:
Stored size: 761 Bytes
Contents
#!/usr/bin/env ruby require 'exalted_math/node/node' module ExaltedMath class Node class Operator < Node attr_reader :left, :right def initialize(left, right) @left = left @right = right end def constant? left.constant? and right.constant? end def value(context={}) raise NotImplementedError end def simplify if constant? Number.new(value) else self.class.new(left.simplify, right.simplify) end end def ==(o) return false unless self.class === o left == o.left && right == o.right end def valid?(stats=[]) left.valid?(stats) && right.valid?(stats) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
exalted_math-0.2.2 | lib/exalted_math/node/operator.rb |
exalted_math-0.2.1 | lib/exalted_math/node/operator.rb |
exalted_math-0.2.0 | lib/exalted_math/node/operator.rb |