Class: Baldrick::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/baldrick/task.rb

Instance Method Summary collapse

Constructor Details

#initialize(matcher, procedure) ⇒ Task

Returns a new instance of Task.



3
4
5
# File 'lib/baldrick/task.rb', line 3

def initialize(matcher, procedure)
  @matcher, @procedure = matcher, procedure
end

Instance Method Details

#run(order) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/baldrick/task.rb', line 7

def run order
  if matches = @matcher.match(order[:what])
    all_arguments = matches[1..-1] << order
    accepted_arguments = all_arguments[0..(@procedure.arity - 1)]
    @procedure.call(*accepted_arguments)
  end
end