TaskAguments manage the arguments passed to a task.
Methods
Included Modules
- Enumerable
Attributes
| [R] | names |
Public Class methods
Create a TaskArgument object with a list of named arguments (given by :names) and a set of associated values (given by :values). :parent is the parent argument object.
[ show source ]
# File lib/rake.rb, line 341
341: def initialize(names, values, parent=nil)
342: @names = names
343: @parent = parent
344: @hash = {}
345: names.each_with_index { |name, i|
346: @hash[name.to_sym] = values[i] unless values[i].nil?
347: }
348: end
Public Instance methods
Find an argument value by name or index.
[ show source ]
# File lib/rake.rb, line 358
358: def [](index)
359: lookup(index.to_sym)
360: end
[ show source ]
# File lib/rake.rb, line 369
369: def each(&block)
370: @hash.each(&block)
371: end
[ show source ]
# File lib/rake.rb, line 385
385: def inspect
386: to_s
387: end
[ show source ]
# File lib/rake.rb, line 373
373: def method_missing(sym, *args, &block)
374: lookup(sym.to_sym)
375: end
Create a new argument scope using the prerequisite argument names.
[ show source ]
# File lib/rake.rb, line 352
352: def new_scope(names)
353: values = names.collect { |n| self[n] }
354: self.class.new(names, values, self)
355: end
[ show source ]
# File lib/rake.rb, line 377
377: def to_hash
378: @hash
379: end
[ show source ]
# File lib/rake.rb, line 381
381: def to_s
382: @hash.inspect
383: end
Specify a hash of default values for task arguments. Use the defaults only if there is no specific value for the given argument.
[ show source ]
# File lib/rake.rb, line 365
365: def with_defaults(defaults)
366: @hash = defaults.merge(@hash)
367: end
Protected Instance methods
[ show source ]
# File lib/rake.rb, line 391
391: def lookup(name)
392: if @hash.has_key?(name)
393: @hash[name]
394: elsif ENV.has_key?(name.to_s)
395: ENV[name.to_s]
396: elsif ENV.has_key?(name.to_s.upcase)
397: ENV[name.to_s.upcase]
398: elsif @parent
399: @parent.lookup(name)
400: end
401: end