Class: LIS::Options
- Inherits:
-
Hash
- Object
- Hash
- LIS::Options
- Defined in:
- lib/lis/commands/application.rb
Instance Attribute Summary (collapse)
-
- (Object) opts
readonly
Returns the value of attribute opts.
Instance Method Summary (collapse)
-
- (Options) initialize(args)
constructor
A new instance of Options.
Constructor Details
- (Options) initialize(args)
A new instance of Options
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 |
# File 'lib/lis/commands/application.rb', line 7 def initialize(args) super() = { :port => "/dev/ttyUSB0", :uri => "http://localhost/lis/" } self.merge!() @opts = OptionParser.new do |o| appname = File.basename($0) o. = "Usage: #{appname} [options]" o.on('-l, --listen PORT', 'which port to listen on (default: "/dev/ttyUSB0")') do |port| self[:port] = port end o.on('-e, --endpoint URI', 'HTTP endpoint (default: "http://localhost/lis/")') do |endpoint| self[:uri] = endpoint end o.on("-v", "--[no-]verbose", "Run verbosely") do |v| $VERBOSE = v self[:verbose] = v end end begin @opts.parse!(args) self[:project_name] = args.shift rescue OptionParser::ParseError => e self[:invalid_argument] = e. end end |
Instance Attribute Details
- (Object) opts (readonly)
Returns the value of attribute opts
5 6 7 |
# File 'lib/lis/commands/application.rb', line 5 def opts @opts end |