class AbstractMapper::Rules::Pair
The base class for rules to be applied to pairs of nodes.
The subclass should implement two instance methods:
-
`#optimize?` to check if the optimization should be applied to the nodes
-
`#optimize` that should return the merged node
@example
class MergeConsecutiveLists < AbstractMapper::Rules::Pair def optimize? left.is_a?(List) & right.is_a?(List) end def optimize List.new { left.entries + right.entries } end end
@abstract
@api public
Attributes
left[R]
@!attribute [r] node
@return [AbstractMapper::AST::Node] The left node in the pair
right[R]
@!attribute [r] node
@return [AbstractMapper::AST::Node] The right node in the pair
Public Class Methods
new(left, right)
click to toggle source
@private
Calls superclass method
AbstractMapper::Rules::Base::new
# File lib/abstract_mapper/rules/pair.rb, line 58 def initialize(left, right) @left = left @right = right super end
Private Class Methods
composer()
click to toggle source
@private
# File lib/abstract_mapper/rules/pair.rb, line 32 def self.composer :compact end