Class: IDL::OptionList::Option::Group
- Inherits:
-
Object
- Object
- IDL::OptionList::Option::Group
- Defined in:
- lib/ridl/optparse_ext.rb
Defined Under Namespace
Classes: Configurator, ParamSet
Instance Attribute Summary collapse
-
#sets ⇒ Object
readonly
Configurator.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(id, options) ⇒ Group
constructor
A new instance of Group.
- #run(arg, options) ⇒ Object
Constructor Details
#initialize(id, options) ⇒ Group
Returns a new instance of Group.
200 201 202 203 204 205 206 207 |
# File 'lib/ridl/optparse_ext.rb', line 200 def initialize(id, ) @test = [:test] || true @description = Array === [:description] ? [:description] : ([:description] || '').split('\n') @sets = {} if [:params] && Hash === [:params] @sets[id] = ParamSet.new(:params => [:params]) end end |
Instance Attribute Details
#sets ⇒ Object (readonly)
Configurator
199 200 201 |
# File 'lib/ridl/optparse_ext.rb', line 199 def sets @sets end |
Instance Method Details
#description ⇒ Object
209 210 211 |
# File 'lib/ridl/optparse_ext.rb', line 209 def description @sets.values.inject(@description.dup) {|desc, a| desc.concat(a.description) } end |
#run(arg, options) ⇒ Object
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/ridl/optparse_ext.rb', line 213 def run(arg, ) ext_args = [] if self.respond_to?(:_prepare, true) result = _prepare(arg, ) 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, , *ext_args) end |