Method: ALib::AbstractMain.argument

Defined in:
lib/alib-0.5.1/main.rb

.argumentObject



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/alib-0.5.1/main.rb', line 263

def required_arguments(*list)
#--{{{
  @required_arguments ||= []
  list.flatten.each do |arg| 
    return(optional_argument(arg)) if Hash === arg
    unless instance_methods.include? "#{ arg }"
      module_eval <<-code
        def #{ arg }(*__list)
          if __list.empty?
            @#{ arg }
          else
            send('#{ arg }=', *__list)
          end
        end
        def #{ arg }=(__arg, *__list)
          if __list.empty?
            @#{ arg } = __arg
          else
            @#{ arg } = ([__arg] + __list)
          end
        end
        def #{ arg }?
          defined? @#{ arg } and @#{ arg }
        end
      code
    end
    @required_arguments << "#{ arg }"
  end
  @required_arguments
#--}}}
end