class IDL::OptionList
Public Class Methods
new()
click to toggle source
# File lib/ridl/optparse_ext.rb, line 325 def initialize @options = {} end
Public Instance Methods
define_switch(switch, options = {}, &block)
click to toggle source
# File lib/ridl/optparse_ext.rb, line 329 def define_switch(switch, options = {}, &block) switch = switch.to_s raise "switch types mismatch" if @options.has_key?(switch) && options[:type] && options[:type] != @options[switch].type @options[switch] ||= Option.new(switch, options) block.call(Option::Configurator.new(@options[switch])) if block_given? end
Also aliased as: for_switch, switch
to_option_parser(optp, option_holder)
click to toggle source
# File lib/ridl/optparse_ext.rb, line 344 def to_option_parser(optp, option_holder) @options.each do |sw, op| (arg_list = [sw]) << op.type arg_list.concat(op.description(optp.summary_indent)) optp.on(*arg_list) do |v| op.run(v, option_holder.options) end optp.separator '' if op.separator end end
undefine_switch(switch)
click to toggle source
# File lib/ridl/optparse_ext.rb, line 339 def undefine_switch(switch) switch = switch.to_s @options.delete(switch) end