class Dentaku::AST::Modulo
Public Class Methods
arity()
click to toggle source
# File lib/dentaku/ast/arithmetic.rb, line 181 def self.arity @arity end
new(left, right = nil)
click to toggle source
# File lib/dentaku/ast/arithmetic.rb, line 190 def initialize(left, right = nil) if right @left = left @right = right else @right = left end unless valid_left? raise NodeError.new(%i[numeric nil], left.type, :left), "#{self.class} requires numeric operands or nil" end unless valid_right? raise NodeError.new(:numeric, right.type, :right), "#{self.class} requires numeric operands" end end
peek(input)
click to toggle source
# File lib/dentaku/ast/arithmetic.rb, line 185 def self.peek(input) @arity = 1 @arity = 2 if input.length > 1 end
precedence()
click to toggle source
# File lib/dentaku/ast/arithmetic.rb, line 232 def self.precedence 20 end
Public Instance Methods
dependencies(context = {})
click to toggle source
Calls superclass method
# File lib/dentaku/ast/arithmetic.rb, line 208 def dependencies(context = {}) if percent? @right.dependencies(context) else super end end
operator()
click to toggle source
# File lib/dentaku/ast/arithmetic.rb, line 228 def operator :% end
percent?()
click to toggle source
# File lib/dentaku/ast/arithmetic.rb, line 216 def percent? left.nil? end
valid_left?()
click to toggle source
# File lib/dentaku/ast/arithmetic.rb, line 236 def valid_left? valid_node?(left) || left.nil? end
value(context = {})
click to toggle source
Calls superclass method
Dentaku::AST::Arithmetic#value
# File lib/dentaku/ast/arithmetic.rb, line 220 def value(context = {}) if percent? cast(right.value(context)) * 0.01 else super end end