class Rake::TaskArguments
TaskArguments manage the arguments passed to a task.
#
def [](index)
def [](index) lookup(index.to_sym) end
def each(&block)
def each(&block) @hash.each(&block) end
def extras
def extras @values[@names.length..-1] || [] end
def fetch(*args, &block)
def fetch(*args, &block) @hash.fetch(*args, &block) end
def has_key?(key)
def has_key?(key) @hash.has_key?(key) end
def initialize(names, values, parent=nil)
Create a TaskArgument object with a list of argument +names+ and a set
def initialize(names, values, parent=nil) @names = names @parent = parent @hash = {} @values = values names.each_with_index { |name, i| next if values[i].nil? || values[i] == "" @hash[name.to_sym] = values[i] } end
def inspect # :nodoc:
def inspect # :nodoc: inspection = @hash.map do |k,v| "#{k.to_s}: #{v.to_s}" end.join(", ") "#<#{self.class} #{inspection}>" end
def lookup(name) # :nodoc:
def lookup(name) # :nodoc: if @hash.has_key?(name) @hash[name] elsif @parent @parent.lookup(name) end end
def method_missing(sym, *args)
def method_missing(sym, *args) lookup(sym.to_sym) end
def new_scope(names)
Create a new argument scope using the prerequisite argument
def new_scope(names) values = names.map { |n| self[n] } self.class.new(names, values + extras, self) end
def to_a
def to_a @values.dup end
def to_hash
def to_hash @hash.dup end
def to_s # :nodoc:
def to_s # :nodoc: inspect end
def values_at(*keys)
def values_at(*keys) keys.map { |k| lookup(k) } end
def with_defaults(defaults)
defaults only if there is no specific value for the given
Specify a hash of default values for task arguments. Use the
def with_defaults(defaults) @hash = defaults.merge(@hash) end