Class: FootStats::Live::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/foot_stats/live_player.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Player

Returns a new instance of Player.



6
7
8
9
10
11
12
13
14
15
# File 'lib/foot_stats/live_player.rb', line 6

def initialize(params)
  @source_id       = params["@IdJogador"].to_i
  @name            = params["@Jogador"]
  @status          = params["@Status"]
  @was_substituted = params["@Substituto"] != ''
  @period          = params["@Periodo"]
  @minute          = params["@Minuto"].to_i

  @substituted = params["@Substituto"] if @was_substituted
end

Instance Attribute Details

#minuteObject (readonly)

Returns the value of attribute minute.



4
5
6
# File 'lib/foot_stats/live_player.rb', line 4

def minute
  @minute
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/foot_stats/live_player.rb', line 4

def name
  @name
end

#periodObject (readonly)

Returns the value of attribute period.



4
5
6
# File 'lib/foot_stats/live_player.rb', line 4

def period
  @period
end

#source_idObject (readonly)

Returns the value of attribute source_id.



4
5
6
# File 'lib/foot_stats/live_player.rb', line 4

def source_id
  @source_id
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/foot_stats/live_player.rb', line 4

def status
  @status
end

#substitutedObject (readonly)

Returns the value of attribute substituted.



4
5
6
# File 'lib/foot_stats/live_player.rb', line 4

def substituted
  @substituted
end

#was_substitutedObject (readonly) Also known as: substituted?

Returns the value of attribute was_substituted.



4
5
6
# File 'lib/foot_stats/live_player.rb', line 4

def was_substituted
  @was_substituted
end

Class Method Details

.diff(players, old_players_ids) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/foot_stats/live_player.rb', line 19

def self.diff(players, old_players_ids)
  new_players_ids = players.map &:source_id
  {
    added:   (new_players_ids - old_players_ids),
    removed: (old_players_ids - new_players_ids)
  }
end