class Rake::TaskArguments
TaskArguments
manage the arguments passed to a task.
Attributes
Public Class Methods
Source
# File lib/rake/task_arguments.rb 14 def initialize(names, values, parent=nil) 15 @names = names 16 @parent = parent 17 @hash = {} 18 names.each_with_index { |name, i| 19 @hash[name.to_sym] = values[i] unless values[i].nil? 20 } 21 end
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.
Public Instance Methods
Source
# File lib/rake/task_arguments.rb 31 def [](index) 32 lookup(index.to_sym) 33 end
Find an argument value by name or index.
Source
# File lib/rake/task_arguments.rb 42 def each(&block) 43 @hash.each(&block) 44 end
Source
# File lib/rake/task_arguments.rb 46 def method_missing(sym, *args, &block) 47 lookup(sym.to_sym) 48 end
Source
# File lib/rake/task_arguments.rb 25 def new_scope(names) 26 values = names.collect { |n| self[n] } 27 self.class.new(names, values, self) 28 end
Create a new argument scope using the prerequisite argument names.
Source
# File lib/rake/task_arguments.rb 38 def with_defaults(defaults) 39 @hash = defaults.merge(@hash) 40 end
Specify a hash of default values for task arguments. Use the defaults only if there is no specific value for the given argument.
Protected Instance Methods
Source
# File lib/rake/task_arguments.rb 64 def lookup(name) 65 if @hash.has_key?(name) 66 @hash[name] 67 elsif @parent 68 @parent.lookup(name) 69 end 70 end