Sha256: f09fe87e1711a64f887e44f9b41af6da51d3460c30fc1ec8065a7359db74fcc0

Contents?: true

Size: 853 Bytes

Versions: 1

Compression:

Stored size: 853 Bytes

Contents

module FootStats
  class Live < Resource
    class Player
      attr_reader :source_id, :name, :status, :was_substituted, :substituted, :period, :minute

      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

      alias :substituted? :was_substituted

      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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foot_stats-0.1.0 lib/foot_stats/live_player.rb