Method: UPnP::Device.run
- Defined in:
- lib/UPnP/device.rb
.run(argv = ARGV) ⇒ Object
Processes argv, but must be overridden in a subclass to create and run the device.
Override this in a subclass. The overriden run should super, then #create a device using @options as parsed by option_parser, then call #run on the created device.
Example:
def self.run(argv = ARGV)
super
device = create 'MyDevice' do |md|
md.manufacturer = '...'
# device-specific setup
end
device.run
end
run takes care of invalid arguments and options for you by printing out the help followed by the invalid argument.
347 348 349 350 351 352 353 354 355 356 |
# File 'lib/UPnP/device.rb', line 347 def self.run(argv = ARGV) option_parser.parse argv rescue OptionParser::InvalidOption, OptionParser::InvalidArgument, OptionParser::NeedlessArgument => e puts option_parser puts puts e exit 1 end |