Class: SimulatorTimeline::EventHandler
- Inherits:
-
Object
- Object
- SimulatorTimeline::EventHandler
- Defined in:
- app/models/simulator_timeline/event_handler.rb
Instance Method Summary collapse
- #add_card(player, options = {}) ⇒ Object
- #add_goal(player, options = {}) ⇒ Object
- #add_red_card(player, options = {}) ⇒ Object
- #add_yellow_card(player, options = {}) ⇒ Object
- #escalation(players) ⇒ Object
-
#initialize(timeline, period_time, minute) ⇒ EventHandler
constructor
A new instance of EventHandler.
- #narration(message_name = :lorem, options = {}) ⇒ Object
- #player(player, options = {}) ⇒ Object
- #remove_card(reference) ⇒ Object
- #remove_goal(reference) ⇒ Object
- #remove_narration(reference) ⇒ Object
- #remove_player(reference) ⇒ Object
Constructor Details
#initialize(timeline, period_time, minute) ⇒ EventHandler
Returns a new instance of EventHandler.
3 4 5 |
# File 'app/models/simulator_timeline/event_handler.rb', line 3 def initialize(timeline, period_time, minute) @timeline, @period_time, @minute = timeline, period_time, minute end |
Instance Method Details
#add_card(player, options = {}) ⇒ Object
16 17 18 19 |
# File 'app/models/simulator_timeline/event_handler.rb', line 16 def add_card(player, ={}) = { player: player }.merge() CardEvent.new self, @timeline, @period_time, @minute, end |
#add_goal(player, options = {}) ⇒ Object
7 8 9 10 |
# File 'app/models/simulator_timeline/event_handler.rb', line 7 def add_goal(player, ={}) = { player: player }.merge() GoalEvent.new self, @timeline, @period_time, @minute, end |
#add_red_card(player, options = {}) ⇒ Object
26 27 28 29 |
# File 'app/models/simulator_timeline/event_handler.rb', line 26 def add_red_card(player, ={}) = { player: player, type: :red }.merge() add_card player, end |
#add_yellow_card(player, options = {}) ⇒ Object
21 22 23 24 |
# File 'app/models/simulator_timeline/event_handler.rb', line 21 def add_yellow_card(player, ={}) = { player: player, type: :yellow }.merge() add_card player, end |
#escalation(players) ⇒ Object
35 36 37 38 39 |
# File 'app/models/simulator_timeline/event_handler.rb', line 35 def escalation(players) players.each do |player| self.player(player) end end |
#narration(message_name = :lorem, options = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'app/models/simulator_timeline/event_handler.rb', line 50 def narration( = :lorem, = {}) = if .is_a?(String) else = Lorem.new(@timeline, @period_time, @minute, ).public_send end = { message: }.merge() NarrationEvent.new self, @timeline, @period_time, @minute, end |
#player(player, options = {}) ⇒ Object
41 42 43 44 |
# File 'app/models/simulator_timeline/event_handler.rb', line 41 def player(player, ={}) = { player: player }.merge() PlayerEvent.new self, @timeline, @period_time, @minute, end |
#remove_card(reference) ⇒ Object
31 32 33 |
# File 'app/models/simulator_timeline/event_handler.rb', line 31 def remove_card(reference) CardEvent.remove @timeline, reference end |
#remove_goal(reference) ⇒ Object
12 13 14 |
# File 'app/models/simulator_timeline/event_handler.rb', line 12 def remove_goal(reference) GoalEvent.remove @timeline, reference end |
#remove_narration(reference) ⇒ Object
60 61 62 |
# File 'app/models/simulator_timeline/event_handler.rb', line 60 def remove_narration(reference) NarrationEvent.remove @timeline, reference end |
#remove_player(reference) ⇒ Object
46 47 48 |
# File 'app/models/simulator_timeline/event_handler.rb', line 46 def remove_player(reference) PlayerEvent.remove @timeline, reference end |