Class: RubyCritic::Cli::Options

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

Defined Under Namespace

Classes: Argv, File

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Options

Returns a new instance of Options.



11
12
13
14
# File 'lib/rubycritic/cli/options.rb', line 11

def initialize(argv)
  @argv_options = Argv.new(argv)
  @file_options = File.new
end

Instance Attribute Details

#argv_optionsObject (readonly)

Returns the value of attribute argv_options.



9
10
11
# File 'lib/rubycritic/cli/options.rb', line 9

def argv_options
  @argv_options
end

#file_optionsObject (readonly)

Returns the value of attribute file_options.



9
10
11
# File 'lib/rubycritic/cli/options.rb', line 9

def file_options
  @file_options
end

Instance Method Details

#parseObject



16
17
18
19
20
# File 'lib/rubycritic/cli/options.rb', line 16

def parse
  argv_options.parse
  file_options.parse
  self
end

#to_hObject

:reek:NilCheck



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

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