Class: ConventionalModels::OptionParser
- Inherits:
-
Object
- Object
- ConventionalModels::OptionParser
- Defined in:
- lib/conventional_models/option_parser.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(arguments) ⇒ OptionParser
constructor
A new instance of OptionParser.
- #parse ⇒ Object
- #parsed_options? ⇒ Boolean
Constructor Details
#initialize(arguments) ⇒ OptionParser
Returns a new instance of OptionParser.
11 12 13 14 15 16 17 18 |
# File 'lib/conventional_models/option_parser.rb', line 11 def initialize(arguments) @arguments = arguments @options = Options.new @parsed_options = true parse end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/conventional_models/option_parser.rb', line 9 def @options end |
Instance Method Details
#parse ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/conventional_models/option_parser.rb', line 24 def parse opts = ::OptionParser.new opts.on('-v', '--version') { @options.output_version = true } opts.on('-h', '--help') { @options.output_help = true } opts.on('-s', '--skip-configure') { @options.skip_configure = true } opts.on('-c', '--config FILE') { |file| @options.config = file } opts.on('-e', '--environment ENV') { |env| @options.environment = env } opts.on('-V', '--verbose') { |env| @options.verbose = true } opts.parse!(@arguments) rescue @parsed_options = false end |
#parsed_options? ⇒ Boolean
20 21 22 |
# File 'lib/conventional_models/option_parser.rb', line 20 def @parsed_options end |