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 322 322: def initialize(names, values, parent=nil) 323: @names = names 324: @parent = parent 325: @hash = {} 326: names.each_with_index { |name, i| 327: @hash[name.to_sym] = values[i] unless values[i].nil? 328: } 329: end
Public Instance methods
Find an argument value by name or index.
[ show source ]
# File lib/rake.rb, line 339 339: def [](index) 340: lookup(index.to_sym) 341: end
[ show source ]
# File lib/rake.rb, line 350 350: def each(&block) 351: @hash.each(&block) 352: end
[ show source ]
# File lib/rake.rb, line 366 366: def inspect 367: to_s 368: end
[ show source ]
# File lib/rake.rb, line 354 354: def method_missing(sym, *args, &block) 355: lookup(sym.to_sym) 356: end
Create a new argument scope using the prerequisite argument names.
[ show source ]
# File lib/rake.rb, line 333 333: def new_scope(names) 334: values = names.collect { |n| self[n] } 335: self.class.new(names, values, self) 336: end
[ show source ]
# File lib/rake.rb, line 358 358: def to_hash 359: @hash 360: end
[ show source ]
# File lib/rake.rb, line 362 362: def to_s 363: @hash.inspect 364: 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 346 346: def with_defaults(defaults) 347: @hash = defaults.merge(@hash) 348: end
Protected Instance methods
[ show source ]
# File lib/rake.rb, line 372 372: def lookup(name) 373: if @hash.has_key?(name) 374: @hash[name] 375: elsif ENV.has_key?(name.to_s) 376: ENV[name.to_s] 377: elsif ENV.has_key?(name.to_s.upcase) 378: ENV[name.to_s.upcase] 379: elsif @parent 380: @parent.lookup(name) 381: end 382: end