Class: Limited::Actor

Inherits:
Object
  • Object
show all
Defined in:
lib/limited/actor.rb

Defined Under Namespace

Classes: Identifier

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier, values, num_executed = 0) ⇒ Actor

Returns a new instance of Actor.

Raises:

  • (ArgumentError)


23
24
25
26
27
28
29
30
# File 'lib/limited/actor.rb', line 23

def initialize(identifier, values, num_executed = 0)
  raise ArgumentError.new("first parameter needs to be an identifier") unless identifier.is_a?(Identifier)
  raise ArgumentError.new("second parameter needs to be a hash of values") unless values.is_a?(Hash)
  raise ArgumentError.new("the values given in the second parameter needs to match with the keys of the identifier") unless identifier.keys.sort == values.keys.sort

  @attributes = values
  @num_executed = num_executed
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



20
21
22
# File 'lib/limited/actor.rb', line 20

def attributes
  @attributes
end

#num_executedObject

Returns the value of attribute num_executed.



21
22
23
# File 'lib/limited/actor.rb', line 21

def num_executed
  @num_executed
end

Instance Method Details

#executeObject



32
33
34
# File 'lib/limited/actor.rb', line 32

def execute
  @num_executed += 1
end