class Rake::TaskArguments


TaskArguments manage the arguments passed to a task.
#

def [](index)

Find an argument value by name or index.
def [](index)
  lookup(index.to_sym)
end

def each(&block)

Enumerates the arguments and their values
def each(&block)
  @hash.each(&block)
end

def extras

Retrieve the list of values not associated with named arguments
def extras
  @values[@names.length..-1] || []
end

def fetch(*args, &block)

def fetch(*args, &block)
  @hash.fetch(*args, &block)
end

def has_key?(key)

Returns true if +key+ is one of the arguments
def has_key?(key)
  @hash.has_key?(key)
end

def initialize(names, values, parent=nil)

of associated +values+. +parent+ is the parent argument object.
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:

: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:

:nodoc:
def lookup(name) # :nodoc:
  if @hash.has_key?(name)
    @hash[name]
  elsif @parent
    @parent.lookup(name)
  end
end

def method_missing(sym, *args)

Returns the value of the given argument via method_missing
def method_missing(sym, *args)
  lookup(sym.to_sym)
end

def new_scope(names)

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

Retrieve the complete array of sequential values
def to_a
  @values.dup
end

def to_hash

Returns a Hash of arguments and their values
def to_hash
  @hash.dup
end

def to_s # :nodoc:

:nodoc:
def to_s # :nodoc:
  inspect
end

def values_at(*keys)

Extracts the argument values at +keys+
def values_at(*keys)
  keys.map { |k| lookup(k) }
end

def with_defaults(defaults)

argument.
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