Class: HammerCLI::Options::OptionCollector

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recognised_options, option_processor) ⇒ OptionCollector

Returns a new instance of OptionCollector.



6
7
8
9
10
11
12
13
14
# File 'lib/hammer_cli/options/option_collector.rb', line 6

def initialize(recognised_options, option_processor)
  @recognised_options = recognised_options

  if !option_processor.is_a?(HammerCLI::Options::ProcessorList)
    @option_processor = HammerCLI::Options::ProcessorList.new(option_processor)
  else
    @option_processor = option_processor
  end
end

Instance Attribute Details

#option_processorObject

Returns the value of attribute option_processor.



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

def option_processor
  @option_processor
end

Instance Method Details

#all_optionsObject



20
21
22
# File 'lib/hammer_cli/options/option_collector.rb', line 20

def all_options
  @all_options ||= translate_nils(all_options_raw)
end

#all_options_rawObject



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

def all_options_raw
  @all_options_raw ||= @option_processor.process(@recognised_options, {})
end

#optionsObject



24
25
26
# File 'lib/hammer_cli/options/option_collector.rb', line 24

def options
  @options ||= all_options.reject { |key, value| value.nil? && all_options_raw[key].nil? }
end