Class: AbstractMapper::Rule Abstract Private
- Inherits:
-
Object
- Object
- AbstractMapper::Rule
- Defined in:
- lib/abstract_mapper/rule.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 nodes optimization rules
Instance Attribute Summary collapse
-
#nodes ⇒ Array<AbstractMapper::Node>
readonly
private
Either one or two nodes to be optimized.
Class Method Summary collapse
-
.call ⇒ Array<AbstractMapper::Node>
private
Returns the result of the rule applied to the initialized [#nodes].
- .initialize(*nodes) ⇒ Object private
-
.new(*nodes) ⇒ AbstractMapper::Rule
Creates 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).
-
.transproc ⇒ Transproc::Function
private
The transformation function that applies the rule to the array of nodes.
Instance Attribute Details
#nodes ⇒ Array<AbstractMapper::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.
32 33 34 |
# File 'lib/abstract_mapper/rule.rb', line 32 def nodes @nodes end |
Class Method Details
.call ⇒ Array<AbstractMapper::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]
67 68 69 |
# File 'lib/abstract_mapper/rule.rb', line 67 def call optimize? ? [optimize].flatten.compact : nodes end |
.initialize(*nodes) ⇒ 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.
43 44 45 46 |
# File 'lib/abstract_mapper/rule.rb', line 43 def initialize(*nodes) @nodes = nodes IceNine.deep_freeze(self) end |
.new(*nodes) ⇒ AbstractMapper::Rule
Creates the rule for a sole node, or a pair of consecutive nodes
|
|
# File 'lib/abstract_mapper/rule.rb', line 34
|
.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)
59 60 61 |
# File 'lib/abstract_mapper/rule.rb', line 59 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)
52 53 |
# File 'lib/abstract_mapper/rule.rb', line 52 def optimize? end |
.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
23 24 25 |
# File 'lib/abstract_mapper/rule.rb', line 23 def self.transproc Functions[composer, proc { |*nodes| new(*nodes).call }] end |