Actions
Bug #19566
closedOptionParser::on raises unsupported argument type: URI (ArgumentError) but shouldn't
Bug #19566:
OptionParser::on raises unsupported argument type: URI (ArgumentError) but shouldn't
Description
The documentation says
OptionParser comes with a few ready-to-use kinds of type coercion. They are
..
- URI – Anything accepted by URI.parse
But when I try to use the class URI as a coercion class:
op = OptionParser.new
op.on("--uri URI", URI)
I get: unsupported argument type: URI (ArgumentError).
The workaround is to register it with accept:
op = OptionParser.new
op.accept(URI, &URI.method(:parse))
op.on("--uri URI", URI)
I attached 2 files, the first one ruby-op-uri-bug.rb displays the Error.
The second one, ruby-op-uri-workaround.rb show the proper output.
Files
Actions