class IDL::OptionList::Option::Group

Attributes

sets[R]

Public Class Methods

new(id, options) click to toggle source
# File lib/ridl/optparse_ext.rb, line 199
def initialize(id, options)
  @test = options[:test] || true
  @description = Array === options[:description] ? options[:description] : (options[:description] || '').split('\n')
  @sets = {}
  if options[:params] && Hash === options[:params]
    @sets[id] = ParamSet.new(params: options[:params])
  end
end

Public Instance Methods

description() click to toggle source
# File lib/ridl/optparse_ext.rb, line 208
def description
  @sets.values.inject(@description.dup) { |desc, a| desc.concat(a.description) }
end
run(arg, options) click to toggle source
# File lib/ridl/optparse_ext.rb, line 212
def run(arg, options)
  ext_args = []
  if self.respond_to?(:_prepare, true)
    result = _prepare(arg, options)
    return false unless result && !result.empty?

    arg = result.shift
    ext_args = result
  else
    case @test
    when TrueClass
    when Regexp
      return false unless @test =~ arg
    else
      return false unless @test == arg
    end
  end
  return handle_sets(arg, options, *ext_args)
end

Private Instance Methods

handle_sets(param, options, *ext_args) click to toggle source
# File lib/ridl/optparse_ext.rb, line 234
def handle_sets(param, options, *ext_args)
  @sets.values.inject(false) { |f, s| s.run(param, options, *ext_args) || f }
end