Class: Feedigest::OptionParser

Inherits:
Object
  • Object
show all
Defined in:
lib/feedigest/option_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ OptionParser

Returns a new instance of OptionParser.



7
8
9
# File 'lib/feedigest/option_parser.rb', line 7

def initialize(args)
  @args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



5
6
7
# File 'lib/feedigest/option_parser.rb', line 5

def args
  @args
end

Instance Method Details

#optionsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/feedigest/option_parser.rb', line 11

def options
  options = build_options
  parser = Slop::Parser.new(options)

  begin
    parser.parse(args).to_hash
  rescue Slop::Error => e
    puts "error: #{e.message}"
    puts
    puts options
    exit
  end
end