Class: Panda::Node
- Inherits:
-
Object
- Object
- Panda::Node
- Defined in:
- lib/panda/expressions.rb
Overview
The base class for all Panda tree nodes (except for the object of a comparison).
Direct Known Subclasses
Class Method Summary collapse
-
.define_operator_builders_for(klass) ⇒ Object
Defines instance methods on the invoking class for each operator of klass.
Class Method Details
.define_operator_builders_for(klass) ⇒ Object
Defines instance methods on the invoking class for each operator of klass. Each defined method returns a new instance of klass with the invoking instance as the left operand, the method name as the operator, and the object argument as the right operand. If the method’s operator has a ‘wordy’ alias, the method is aliased by that name.
19 20 21 22 23 24 25 26 |
# File 'lib/panda/expressions.rb', line 19 def self.define_operator_builders_for(klass) klass.operators.each do |operator, op_name| define_method operator do |object| klass.new(self, operator, object) end alias_method(op_name, operator) if op_name end end |