Class: SimulatorTimeline::NarrationEvent

Inherits:
Event
  • Object
show all
Defined in:
app/models/simulator_timeline/narration_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 = {}) ⇒ NarrationEvent

Returns a new instance of NarrationEvent.



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

def initialize(event_handler, timeline, period_time, minute, options = {})
  super(event_handler, timeline, period_time, minute, options)
  @message, @reference = options.values_at :message, :reference
  @source_id = @timeline.timeline_rand(10**7)+1
  @moment    = format "%02d:%02d", period_time, @timeline.timeline_rand(60)
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



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

def message
  @message
end

#momentObject (readonly)

Returns the value of attribute moment.



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

def moment
  @moment
end

#referenceObject (readonly)

Returns the value of attribute reference.



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

def reference
  @reference
end

#source_idObject (readonly)

Returns the value of attribute source_id.



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

def source_id
  @source_id
end

Class Method Details

.remove(timeline, reference) ⇒ Object



26
27
28
# File 'app/models/simulator_timeline/narration_event.rb', line 26

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

.to_foot_stats(array_of_narrations) ⇒ Object



30
31
32
# File 'app/models/simulator_timeline/narration_event.rb', line 30

def self.to_foot_stats(array_of_narrations)
  fuck_collection 'Narracao', array_of_narrations.map(&:to_foot_stats)
end

Instance Method Details

#to_foot_statsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/simulator_timeline/narration_event.rb', line 12

def to_foot_stats
  {
    "@Id"         => @source_id,
    "IdEquipe"    => "",
    "NomeEquipe"  => "",
    "IdJogador"   => "",
    "NomeJogador" => "",
    "Periodo"     => SimulatorMatch::STATUS_MAP[SimulatorMatch::STATUSES[@period_time]],
    "Momento"     => @moment,
    "Descricao"   => @message,
    "Acao"        => ""
  }
end