Class: PoolParty::Optioner
- Includes:
- Configurable
- Defined in:
- lib/poolparty/helpers/optioner.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(args = [], opts = {}, &block) ⇒ Optioner
constructor
A new instance of Optioner.
- #output_version ⇒ Object
- #parse_options(&blk) ⇒ Object
- #process_options ⇒ Object
- #set_default_options ⇒ Object
Methods included from Configurable
Constructor Details
#initialize(args = [], opts = {}, &block) ⇒ Optioner
Returns a new instance of Optioner.
12 13 14 15 16 17 18 19 |
# File 'lib/poolparty/helpers/optioner.rb', line 12 def initialize(args=[], opts={}, &block) @arguments = args @parse_options = opts[:parse_options] ? opts[:parse_options] : true (&block) if @parse_options self end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/poolparty/helpers/optioner.rb', line 10 def @options end |
Instance Method Details
#output_version ⇒ Object
56 57 58 |
# File 'lib/poolparty/helpers/optioner.rb', line 56 def output_version puts version end |
#parse_options(&blk) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/poolparty/helpers/optioner.rb', line 28 def (&blk) opts = OptionParser.new opts. = "Usage: pool [command] [options]" opts.separator "" opts.separator "Options:" opts.on('-V', '--version', 'Display the version') { output_version ; exit 0 } opts.on('-v', '--verbose', 'Be verbose') { @options[:verbose] = true } opts.on('-s [file]', '--spec-file [file]', 'Set the spec file') { |file| self.spec file } opts.on('-t', '--test', 'Testing mode') { self.testing "true" } blk.call(opts, self) if blk opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.parse!(@arguments) if verbose end |
#process_options ⇒ Object
52 53 54 |
# File 'lib/poolparty/helpers/optioner.rb', line 52 def @options[:verbose] = false if @options[:quiet] end |