Class: CukeSalad::Actor
- Inherits:
-
Object
- Object
- CukeSalad::Actor
- Defined in:
- lib/cukesalad/actor.rb
Instance Method Summary collapse
- #get_into_character_for(described_role) ⇒ Object
- #get_ready_to_perform(something) ⇒ Object
-
#initialize(this_type_of_role, directed_by = Director.new) ⇒ Actor
constructor
A new instance of Actor.
- #perform(described_task, details = {}) ⇒ Object (also: #answer)
- #recall(key) ⇒ Object
- #role_preparation ⇒ Object
- #see_how_to_do(something) ⇒ Object (also: #see_how_to)
- #take_note_of(key, value) ⇒ Object
- #value_of(symbol) ⇒ Object
Constructor Details
#initialize(this_type_of_role, directed_by = Director.new) ⇒ Actor
Returns a new instance of Actor.
6 7 8 9 10 |
# File 'lib/cukesalad/actor.rb', line 6 def initialize this_type_of_role, directed_by=Director.new @director = directed_by @note_pad = {} get_into_character_for this_type_of_role end |
Instance Method Details
#get_into_character_for(described_role) ⇒ Object
19 20 21 22 23 |
# File 'lib/cukesalad/actor.rb', line 19 def get_into_character_for described_role the_role = @director.explain_the_role described_role see_how_to_do the_role role_preparation end |
#get_ready_to_perform(something) ⇒ Object
25 26 27 28 |
# File 'lib/cukesalad/actor.rb', line 25 def get_ready_to_perform something the_thing = @director.how_do_i_perform something see_how_to_do the_thing end |
#perform(described_task, details = {}) ⇒ Object Also known as: answer
12 13 14 15 16 |
# File 'lib/cukesalad/actor.rb', line 12 def perform described_task, details = {} get_ready_to_perform described_task @info = details perform_task end |
#recall(key) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/cukesalad/actor.rb', line 47 def recall key begin @note_pad.fetch key rescue KeyError raise KeyError, "You tried to recall ':#{key}' but no previous step appears to have taken note of that information." end end |
#role_preparation ⇒ Object
35 36 37 |
# File 'lib/cukesalad/actor.rb', line 35 def role_preparation # Does nothing unless you override it from your role end |
#see_how_to_do(something) ⇒ Object Also known as: see_how_to
30 31 32 |
# File 'lib/cukesalad/actor.rb', line 30 def see_how_to_do something extend something end |
#take_note_of(key, value) ⇒ Object
43 44 45 |
# File 'lib/cukesalad/actor.rb', line 43 def take_note_of key, value @note_pad.store key, value end |
#value_of(symbol) ⇒ Object
39 40 41 |
# File 'lib/cukesalad/actor.rb', line 39 def value_of(symbol) @info[symbol] end |