Class: OptimistXL::IOOption

Inherits:
Option
  • Object
show all
Defined in:
lib/optimist_xl.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

IOArrayOption

Instance Attribute Summary

Attributes inherited from Option

#default, #long, #max_args, #min_args, #multi_given, #name, #permitted, #permitted_response, #short

Instance Method Summary collapse

Methods inherited from Option

#array_default?, #callback, #compatible_with?, create, #desc, #description_with_default, #description_with_permitted, #doesnt_need_autogen_short, #educate, #format_stdio, #full_description, handle_long_opt, handle_short_opt, #initialize, #multi, #opts, #opts=, #permitted_type_valid?, #permitted_valid_string, #permitted_value?, register_alias, #required?, #validate_permitted

Constructor Details

This class inherits a constructor from OptimistXL::Option

Instance Method Details

#parse(paramlist, _neg_given) ⇒ Object



1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
# File 'lib/optimist_xl.rb', line 1180

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_formatObject



1179
# File 'lib/optimist_xl.rb', line 1179

def type_format ; "=<filename/uri>" ; end