Class: SimulatorTimeline::GoalEvent

Inherits:
Event
  • Object
show all
Defined in:
app/models/simulator_timeline/goal_event.rb

Instance Attribute Summary collapse

Attributes inherited from Event

#event_handler, #minute, #period_time

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Event

#<=>, fuck_collection

Constructor Details

#initialize(event_handler, timeline, period_time, minute, options = {}) ⇒ GoalEvent

Returns a new instance of GoalEvent.



5
6
7
8
9
# File 'app/models/simulator_timeline/goal_event.rb', line 5

def initialize(event_handler, timeline, period_time, minute, options = {})
  @player, @type, @reference = options.values_at :player, :type, :reference
  @type ||= 'Favor'
  super(event_handler, timeline, period_time, minute, options)
end

Instance Attribute Details

#playerObject (readonly)

Returns the value of attribute player.



3
4
5
# File 'app/models/simulator_timeline/goal_event.rb', line 3

def player
  @player
end

#referenceObject (readonly)

Returns the value of attribute reference.



3
4
5
# File 'app/models/simulator_timeline/goal_event.rb', line 3

def reference
  @reference
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'app/models/simulator_timeline/goal_event.rb', line 3

def type
  @type
end

Class Method Details

.remove(timeline, reference) ⇒ Object



20
21
22
23
# File 'app/models/simulator_timeline/goal_event.rb', line 20

def self.remove(timeline, reference)
  timeline.home_goals.delete_if{ |event| event.reference == reference }
  timeline.visitor_goals.delete_if{ |event| event.reference == reference }
end

.to_foot_stats(array_of_goals) ⇒ Object



25
26
27
# File 'app/models/simulator_timeline/goal_event.rb', line 25

def self.to_foot_stats(array_of_goals)
  fuck_collection 'Gol', array_of_goals.map(&:to_foot_stats)
end

Instance Method Details

#to_foot_statsObject



11
12
13
14
15
16
17
18
# File 'app/models/simulator_timeline/goal_event.rb', line 11

def to_foot_stats
  {
    "@Jogador" => @player.full_name,
    "@Periodo" => SimulatorMatch::STATUS_MAP[SimulatorMatch::STATUSES[@period_time]],
    "@Minuto"  => @minute.to_s,
    "@Tipo"    => @type
  }
end