Class: AbstractMapper::Rules::Base Abstract Private
- Inherits:
-
Object
- Object
- AbstractMapper::Rules::Base
- Defined in:
- lib/abstract_mapper/rules/base.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Base class for optimization rules
Instance Attribute Summary collapse
-
#nodes ⇒ Array<AbstractMapper::AST::Node>
readonly
private
Either one or two nodes to be optimized.
Class Method Summary collapse
-
.transproc ⇒ Transproc::Function
private
The transformation function that applies the rule to the array of nodes.
Instance Method Summary collapse
-
#call ⇒ Array<AbstractMapper::AST::Node>
private
Returns the result of the rule applied to the initialized [#nodes].
-
#initialize(*nodes) ⇒ AbstractMapper::Rules::Base
constructor
private
Initializes the rule for a sole node, or a pair of consecutive nodes.
-
#optimize ⇒ Object
private
Returns the optimized node(s).
-
#optimize? ⇒ Boolean
private
Checks if optimization is needed for the node(s).
Constructor Details
#initialize(*nodes) ⇒ AbstractMapper::Rules::Base
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the rule for a sole node, or a pair of consecutive nodes
42 43 44 45 |
# File 'lib/abstract_mapper/rules/base.rb', line 42 def initialize(*nodes) @nodes = nodes IceNine.deep_freeze(self) end |
Instance Attribute Details
#nodes ⇒ Array<AbstractMapper::AST::Node> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Either one or two nodes to be optimized.
34 35 36 |
# File 'lib/abstract_mapper/rules/base.rb', line 34 def nodes @nodes end |
Class Method Details
.transproc ⇒ Transproc::Function
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The transformation function that applies the rule to the array of nodes
25 26 27 |
# File 'lib/abstract_mapper/rules/base.rb', line 25 def self.transproc Functions[composer, proc { |*nodes| new(*nodes).call }] end |
Instance Method Details
#call ⇒ Array<AbstractMapper::AST::Node>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the result of the rule applied to the initialized [#nodes]
66 67 68 |
# File 'lib/abstract_mapper/rules/base.rb', line 66 def call optimize? ? [optimize].flatten.compact : nodes end |
#optimize ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the optimized node(s)
58 59 60 |
# File 'lib/abstract_mapper/rules/base.rb', line 58 def optimize nodes end |
#optimize? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Checks if optimization is needed for the node(s)
51 52 |
# File 'lib/abstract_mapper/rules/base.rb', line 51 def optimize? end |