class Rake::TaskArguments

  1. lib/rake/task_arguments.rb
Parent: Rake

                

TaskArguments manage the arguments passed to a task.

Methods

Public Reader

  1. names

Public Class

  1. new

Public Instance

  1. new_scope
  2. []
  3. with_defaults
  4. each
  5. method_missing
  6. to_hash
  7. to_s
  8. inspect

Protected Instance

  1. lookup

Included modules

  1. Enumerable

Attributes

names [R]

Public Class methods

new (names, values, parent=nil)

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/task_arguments.rb, line 14
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

Public Instance methods

new_scope (names)

Create a new argument scope using the prerequisite argument names.

[show source]
    # File lib/rake/task_arguments.rb, line 25
25:     def new_scope(names)
26:       values = names.collect { |n| self[n] }
27:       self.class.new(names, values, self)
28:     end
[] (index)

Find an argument value by name or index.

[show source]
    # File lib/rake/task_arguments.rb, line 31
31:     def [](index)
32:       lookup(index.to_sym)
33:     end
with_defaults (defaults)

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/task_arguments.rb, line 38
38:     def with_defaults(defaults)
39:       @hash = defaults.merge(@hash)
40:     end
each (&block)
[show source]
    # File lib/rake/task_arguments.rb, line 42
42:     def each(&block)
43:       @hash.each(&block)
44:     end
method_missing (sym, *args, &block)
[show source]
    # File lib/rake/task_arguments.rb, line 46
46:     def method_missing(sym, *args, &block)
47:       lookup(sym.to_sym)
48:     end
to_hash ()
[show source]
    # File lib/rake/task_arguments.rb, line 50
50:     def to_hash
51:       @hash
52:     end
to_s ()
[show source]
    # File lib/rake/task_arguments.rb, line 54
54:     def to_s
55:       @hash.inspect
56:     end
inspect ()
[show source]
    # File lib/rake/task_arguments.rb, line 58
58:     def inspect
59:       to_s
60:     end

Protected Instance methods

lookup (name)
[show source]
    # File lib/rake/task_arguments.rb, line 64
64:     def lookup(name)
65:       if @hash.has_key?(name)
66:         @hash[name]
67:       elsif @parent
68:         @parent.lookup(name)
69:       end
70:     end