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:



32
33
34
# File 'lib/abstract_mapper/rule.rb', line 32

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:



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

Parameters:

Returns:



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


.optimizeObject

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)

Returns:

  • (Object)


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)

Returns:

  • (Boolean)


52
53
# File 'lib/abstract_mapper/rule.rb', line 52

def optimize?
end

.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)


23
24
25
# File 'lib/abstract_mapper/rule.rb', line 23

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