Class: RawQ::Generator::Options
- Inherits:
-
Hash
- Object
- Hash
- RawQ::Generator::Options
- Defined in:
- lib/rawq/generator/options.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rawq/generator/options.rb', line 6 def initialize(args) super() require "optparse" @opts = OptionParser.new do |o| o. = "Usage: #{File.basename($0)} [options] application_name\ne.g. #{File.basename($0)} RawQorApp" o.on("--music-dir [MUSIC_DIR]", "set your music directory") do |music_dir| self[:music_dir] = music_dir end o.separator "" o.on("--username [USERNAME]", "set your username") do |username| self[:username] = username end o.separator "" o.on_tail("-h", "--help", "display this help and exit") do self[:show_help] = true end end begin @opts.parse!(args) self[:application_name] = args.shift rescue OptionParser::InvalidOption => e self[:invalid_option] = e. end end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
4 5 6 |
# File 'lib/rawq/generator/options.rb', line 4 def opts @opts end |