Class: Dentaku::AST::Percentage
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
#type
Methods inherited from Operation
#accept, #display_operator, max_param_count, min_param_count, right_associative?
Methods inherited from Node
#name, #pure?, resolve_class, #type
Constructor Details
#initialize(child) ⇒ Percentage
Returns a new instance of Percentage.
211
212
213
214
215
216
217
218
|
# File 'lib/dentaku/ast/arithmetic.rb', line 211
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
207
208
209
|
# File 'lib/dentaku/ast/arithmetic.rb', line 207
def self.arity
1
end
|
.precedence ⇒ Object
236
237
238
|
# File 'lib/dentaku/ast/arithmetic.rb', line 236
def self.precedence
30
end
|
Instance Method Details
#dependencies(context = {}) ⇒ Object
220
221
222
|
# File 'lib/dentaku/ast/arithmetic.rb', line 220
def dependencies(context = {})
@left.dependencies(context)
end
|
#operator ⇒ Object
228
229
230
|
# File 'lib/dentaku/ast/arithmetic.rb', line 228
def operator
:%
end
|
#operator_spacing ⇒ Object
232
233
234
|
# File 'lib/dentaku/ast/arithmetic.rb', line 232
def operator_spacing
""
end
|
#value(context = {}) ⇒ Object
224
225
226
|
# File 'lib/dentaku/ast/arithmetic.rb', line 224
def value(context = {})
cast(left.value(context)) * 0.01
end
|