class TinyConveyor::Parcel
Encapsulate an action to run in a separated thread
Attributes
description[R]
name[R]
state[R]
uuid[R]
Public Class Methods
new(name, description, action)
click to toggle source
@param name [string] name of the task @param description [string] small description of the task @param action [Proc] action to run in separate thread @return [Parcel] newly created parcel
# File lib/tiny_conveyor/parcel.rb, line 13 def initialize(name, description, action) @name = name @description = description @action = action @state = :pending @uuid = SecureRandom.uuid end
Public Instance Methods
execute()
click to toggle source
# File lib/tiny_conveyor/parcel.rb, line 21 def execute @state = :running @action.call end
running?()
click to toggle source
@return [boolean] true if the parcel is executed, false otherwhise
# File lib/tiny_conveyor/parcel.rb, line 27 def running? @state == :running end