Class: Downer::Options

Inherits:
Hash
  • Object
show all
Defined in:
lib/downer/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Options

Returns a new instance of Options.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/downer/options.rb', line 5

def initialize(args)
  @opts = args.clone
  self[:is_website] = false
  self[:images_only] = false

  @opts = OptionParser.new do |o|
    o.banner = "Usage: downer -flags URL_SOURCE DESTINATION_DIR"
    
    o.on('-i', '--image', 'When combined with w will download JPG,GIF,PNG formats') do
      self[:images_only] = true
    end
  end
  
  begin
    @opts.parse!(args)
    self[:file_manifest] = args.shift
    self[:target_directory] = args.shift
  rescue OptionParser::InvalidOption => e
    self[:invalid_argument] = e.message
  end
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



3
4
5
# File 'lib/downer/options.rb', line 3

def opts
  @opts
end

#orig_argsObject (readonly)

Returns the value of attribute orig_args.



3
4
5
# File 'lib/downer/options.rb', line 3

def orig_args
  @orig_args
end