Class: AbstractMapper::Rule Abstract Private

Inherits:
Object
  • Object
show all
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.

This class is abstract.

Base class for nodes optimization rules

Direct Known Subclasses

PairRule, SoleRule

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#nodesArray<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.

Returns:



26
27
28
# File 'lib/abstract_mapper/rule.rb', line 26

def nodes
  @nodes
end

Class Method Details

.callArray<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]

Returns:



46
47
48
# File 'lib/abstract_mapper/rule.rb', line 46

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.



37
38
39
40
# File 'lib/abstract_mapper/rule.rb', line 37

def initialize(*nodes)
  @nodes = nodes.freeze
  freeze
end

.new(*nodes) ⇒ AbstractMapper::Rule

Creates the rule for a sole node, or a pair of consecutive nodes

Parameters:

Returns:



# File 'lib/abstract_mapper/rule.rb', line 28


.transprocTransproc::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

Returns:

  • (Transproc::Function)


17
18
19
# File 'lib/abstract_mapper/rule.rb', line 17

def self.transproc
  Functions[composer, proc { |*nodes| new(*nodes).call }]
end