Class: Leftovers::Processors::EachForDefinitionSet
- Inherits:
-
Object
- Object
- Leftovers::Processors::EachForDefinitionSet
- Includes:
- ComparableInstance
- Defined in:
- lib/leftovers/processors/each_for_definition_set.rb
Instance Attribute Summary collapse
-
#processors ⇒ Object
readonly
Returns the value of attribute processors.
Instance Method Summary collapse
-
#initialize(processors) ⇒ EachForDefinitionSet
constructor
A new instance of EachForDefinitionSet.
-
#process(str, current_node, matched_node, acc) ⇒ Object
rubocop:disable Metrics/MethodLength.
Methods included from ComparableInstance
Constructor Details
#initialize(processors) ⇒ EachForDefinitionSet
Returns a new instance of EachForDefinitionSet.
10 11 12 13 14 |
# File 'lib/leftovers/processors/each_for_definition_set.rb', line 10 def initialize(processors) @processors = processors freeze end |
Instance Attribute Details
#processors ⇒ Object (readonly)
Returns the value of attribute processors.
8 9 10 |
# File 'lib/leftovers/processors/each_for_definition_set.rb', line 8 def processors @processors end |
Instance Method Details
#process(str, current_node, matched_node, acc) ⇒ Object
rubocop:disable Metrics/MethodLength
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/leftovers/processors/each_for_definition_set.rb', line 16 def process(str, current_node, matched_node, acc) # rubocop:disable Metrics/MethodLength set = DefinitionNodeSet.new @processors.each do |processor| processor.process(str, current_node, matched_node, set) end case set.definitions.length when 1 acc.add_definition_node set.definitions.first when 0 nil else acc.add_definition_set set end end |