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.
223
224
225
226
227
228
229
230
|
# File 'lib/dentaku/ast/arithmetic.rb', line 223
def initialize(child)
@left = child
unless valid_left?
raise NodeError.new(:numeric, left.type, :left),
"#{self.class} requires a numeric operand"
end
end
|
Class Method Details
.arity ⇒ Object
219
220
221
|
# File 'lib/dentaku/ast/arithmetic.rb', line 219
def self.arity
1
end
|
.precedence ⇒ Object
248
249
250
|
# File 'lib/dentaku/ast/arithmetic.rb', line 248
def self.precedence
30
end
|
Instance Method Details
#dependencies(context = {}) ⇒ Object
232
233
234
|
# File 'lib/dentaku/ast/arithmetic.rb', line 232
def dependencies(context = {})
@left.dependencies(context)
end
|
#operator ⇒ Object
240
241
242
|
# File 'lib/dentaku/ast/arithmetic.rb', line 240
def operator
:%
end
|
#operator_spacing ⇒ Object
244
245
246
|
# File 'lib/dentaku/ast/arithmetic.rb', line 244
def operator_spacing
""
end
|
#value(context = {}) ⇒ Object
236
237
238
|
# File 'lib/dentaku/ast/arithmetic.rb', line 236
def value(context = {})
cast(left.value(context)) * 0.01
end
|