Class: Nanite::Job

Inherits:
Object show all
Defined in:
lib/nanite/job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, targets, blk) ⇒ Job

Returns a new instance of Job.



33
34
35
36
37
38
39
# File 'lib/nanite/job.rb', line 33

def initialize(request, targets, blk)
  @request = request
  @targets = targets
  @token = @request.token
  @results = {}
  @completed = blk
end

Instance Attribute Details

#completedObject (readonly)

Returns the value of attribute completed.



31
32
33
# File 'lib/nanite/job.rb', line 31

def completed
  @completed
end

#requestObject (readonly)

Returns the value of attribute request.



31
32
33
# File 'lib/nanite/job.rb', line 31

def request
  @request
end

#resultsObject (readonly)

Returns the value of attribute results.



31
32
33
# File 'lib/nanite/job.rb', line 31

def results
  @results
end

#targetsObject (readonly)

Returns the value of attribute targets.



31
32
33
# File 'lib/nanite/job.rb', line 31

def targets
  @targets
end

#tokenObject (readonly)

Returns the value of attribute token.



31
32
33
# File 'lib/nanite/job.rb', line 31

def token
  @token
end

Instance Method Details

#completed?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/nanite/job.rb', line 46

def completed?
  targets.empty?
end

#process(msg) ⇒ Object



41
42
43
44
# File 'lib/nanite/job.rb', line 41

def process(msg)
  results[msg.from] = msg.results
  targets.delete(msg.from)
end