Class: Skunk::Cli::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/skunk/cli/options.rb,
lib/skunk/cli/options/argv.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Argv

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Options

Returns a new instance of Options.



12
13
14
15
# File 'lib/skunk/cli/options.rb', line 12

def initialize(argv)
  @argv_options = Argv.new(argv)
  @file_options = RubyCritic::Cli::Options::File.new
end

Instance Attribute Details

#argv_optionsObject (readonly)

Returns the value of attribute argv_options.



10
11
12
# File 'lib/skunk/cli/options.rb', line 10

def argv_options
  @argv_options
end

#file_optionsObject (readonly)

Returns the value of attribute file_options.



10
11
12
# File 'lib/skunk/cli/options.rb', line 10

def file_options
  @file_options
end

Instance Method Details

#parseObject



17
18
19
20
21
# File 'lib/skunk/cli/options.rb', line 17

def parse
  argv_options.parse
  file_options.parse
  self
end

#to_hObject

:reek:NilCheck



24
25
26
27
28
29
30
31
# File 'lib/skunk/cli/options.rb', line 24

def to_h
  file_hash = file_options.to_h
  argv_hash = argv_options.to_h

  file_hash.merge(argv_hash) do |_, file_option, argv_option|
    Array(argv_option).empty? ? file_option : argv_option
  end
end