Class: HammerCLI::Options::ProcessorList

Inherits:
Array
  • Object
show all
Defined in:
lib/hammer_cli/options/processor_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sources = [], name: nil) ⇒ ProcessorList

Returns a new instance of ProcessorList.



6
7
8
9
# File 'lib/hammer_cli/options/processor_list.rb', line 6

def initialize(sources = [], name: nil)
  @name = name
  self.push(*sources)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/hammer_cli/options/processor_list.rb', line 4

def name
  @name
end

Instance Method Details

#find_by_name(name) ⇒ Object



16
17
18
# File 'lib/hammer_cli/options/processor_list.rb', line 16

def find_by_name(name)
  self[item_index(name)]
end

#insert_relative(mode, target_name, processor) ⇒ Object



11
12
13
14
# File 'lib/hammer_cli/options/processor_list.rb', line 11

def insert_relative(mode, target_name, processor)
  index = target_name.nil? ? nil : item_index(target_name)
  HammerCLI.insert_relative(self, mode, index, processor)
end

#process(defined_options, result) ⇒ Object



20
21
22
23
24
# File 'lib/hammer_cli/options/processor_list.rb', line 20

def process(defined_options, result)
  self.inject(result) do |all_options, processor|
    processor.process(defined_options, all_options)
  end
end