Class: Dentaku::AST::Percentage
Constant Summary
Constants inherited
from Arithmetic
Arithmetic::DECIMAL, Arithmetic::INTEGER
Instance Attribute Summary
Attributes inherited from Operation
#left, #right
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Arithmetic
#type
Methods inherited from Operation
#accept, #display_operator, max_param_count, min_param_count, right_associative?
Methods inherited from Node
#name, resolve_class, #type
Constructor Details
#initialize(child) ⇒ Percentage
Returns a new instance of Percentage.
203
204
205
206
207
208
209
210
|
# File 'lib/dentaku/ast/arithmetic.rb', line 203
def initialize(child)
@right = child
unless valid_right?
raise NodeError.new(:numeric, right.type, :right),
"#{self.class} requires a numeric operand"
end
end
|
Class Method Details
.arity ⇒ Object
199
200
201
|
# File 'lib/dentaku/ast/arithmetic.rb', line 199
def self.arity
1
end
|
.precedence ⇒ Object
224
225
226
|
# File 'lib/dentaku/ast/arithmetic.rb', line 224
def self.precedence
30
end
|
Instance Method Details
#dependencies(context = {}) ⇒ Object
212
213
214
|
# File 'lib/dentaku/ast/arithmetic.rb', line 212
def dependencies(context = {})
@right.dependencies(context)
end
|
#operator ⇒ Object
220
221
222
|
# File 'lib/dentaku/ast/arithmetic.rb', line 220
def operator
:%
end
|
#value(context = {}) ⇒ Object
216
217
218
|
# File 'lib/dentaku/ast/arithmetic.rb', line 216
def value(context = {})
cast(right.value(context)) * 0.01
end
|