Class: Downer::Options
- Inherits:
-
Hash
- Object
- Hash
- Downer::Options
- Defined in:
- lib/downer/options.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#orig_args ⇒ Object
readonly
Returns the value of attribute orig_args.
Instance Method Summary collapse
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
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. = "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. end end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
3 4 5 |
# File 'lib/downer/options.rb', line 3 def opts @opts end |
#orig_args ⇒ Object (readonly)
Returns the value of attribute orig_args.
3 4 5 |
# File 'lib/downer/options.rb', line 3 def orig_args @orig_args end |