Class: Optimist::IOOption
- Defined in:
- lib/rbcli/components/parser/optimist/optimist.rb
Overview
Option class for handling IO objects and URLs. Note that this will return the file-handle, not the file-name in the case of file-paths given to it.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Option
#default, #long, #multi_given, #name, #permitted, #short
Instance Method Summary collapse
Methods inherited from Option
#array_default?, #callback, create, #desc, #educate, #flag?, #full_description, #initialize, #multi, #multi_arg?, #opts, #opts=, register_alias, #required?, #short?, #single_arg?
Constructor Details
This class inherits a constructor from Optimist::Option
Instance Method Details
#parse(paramlist, _neg_given) ⇒ Object
895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 |
# File 'lib/rbcli/components/parser/optimist/optimist.rb', line 895 def parse(paramlist, _neg_given) paramlist.map do |pg| pg.map do |param| if param =~ /^(stdin|-)$/i $stdin else require 'open-uri' begin open param rescue SystemCallError => e raise CommandlineError, "file or url for option '#{self.name}' cannot be opened: #{e.message}" end end end end end |
#type_format ⇒ Object
891 892 893 |
# File 'lib/rbcli/components/parser/optimist/optimist.rb', line 891 def type_format "=<filename/uri>"; end |