Method: ALib::AbstractMain.required_arguments

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

.required_arguments(*list) ⇒ Object



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/alib-0.5.0/main.rb', line 230

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