Class: Dentaku::AST::Modulo
Constant Summary
Constants inherited
from Node
Node::STATIC_CONTEXT, Node::STATIC_MODE_KEY
Instance Attribute Summary
Attributes inherited from Operation
#left, #right
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Arithmetic
#initialize, #type
Methods inherited from Operation
#accept, #dependencies, #display_operator, #initialize, max_param_count, min_param_count, #operator_spacing, right_associative?
Methods inherited from Node
#dependencies, #name, #pure?, #type
Class Method Details
.arity ⇒ Object
182
183
184
|
# File 'lib/dentaku/ast/arithmetic.rb', line 182
def self.arity
2
end
|
.precedence ⇒ Object
186
187
188
|
# File 'lib/dentaku/ast/arithmetic.rb', line 186
def self.precedence
20
end
|
.resolve_class(next_token) ⇒ Object
190
191
192
|
# File 'lib/dentaku/ast/arithmetic.rb', line 190
def self.resolve_class(next_token)
next_token.nil? || next_token.operator? || next_token.close? ? Percentage : self
end
|
Instance Method Details
#operator ⇒ Object
194
195
196
|
# File 'lib/dentaku/ast/arithmetic.rb', line 194
def operator
:%
end
|
#value(context = {}) ⇒ Object
198
199
200
201
202
203
|
# File 'lib/dentaku/ast/arithmetic.rb', line 198
def value(context = {})
r = decimal(cast(right.value(context)))
raise Dentaku::ZeroDivisionError if r.zero?
cast(cast(left.value(context)) % r)
end
|