Class: Ripe::DSL::TaskDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/ripe/dsl/task_dsl.rb

Overview

This class provides a DSL for defining a task. It should only be called by #task.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handle, &block) ⇒ TaskDSL

Create a new Task DSL

Parameters:

  • handle (String)

    the name of the task

  • block (Proc)

    executes block in the context of TaskDSL



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/ripe/dsl/task_dsl.rb', line 59

def initialize(handle, &block)
  @handle = handle
  @params = {}

  if block_given?
    if block.arity == 1
      yield self
    else
      instance_eval &block
    end
  end
end

Instance Attribute Details

#paramsHash<Symbol, String> (readonly)

list of parameters

Returns:

  • (Hash<Symbol, String>)

    the current value of params



49
50
51
# File 'lib/ripe/dsl/task_dsl.rb', line 49

def params
  @params
end

Instance Method Details

#param(key, value) ⇒ Object

Register a parameter

Parameters:

  • key (Symbol)

    the parameter name

  • value (String)

    its value



78
79
80
# File 'lib/ripe/dsl/task_dsl.rb', line 78

def param(key, value)
  @params.merge!({ key => value })
end