Sha256: 3d2a54c76d43da23f797d25fa1514c7c9cef35b75f85888c3194aad494ebd660

Contents?: true

Size: 1.58 KB

Versions: 5

Compression:

Stored size: 1.58 KB

Contents

module Sportradar
  module Api
    module Soccer
      class Event < Data
        attr_reader :id, :type, :time, :period, :period_type, :period_name, :match_time, :team, :x, :y, :outcome, :home_score, :away_score, :goal_scorer, :stoppage_time, :player_out, :player_in, :player

        def initialize(data, **opts)
          @response       = data
          @id             = data["id"]

          update(data, **opts)
        end

        def update(data, **opts)
          @type           = data['type']
          @time           = Time.parse(data['time']) if data['time']
          @period         = data['period']
          @period_type    = data['period_type']
          @period_name    = data['period_name']
          @match_time     = data['match_time']
          @team           = data['team'] # home/away
          @x              = data['x']
          @y              = data['y']
          @outcome        = data['outcome']
          @home_score     = data['home_score']
          @away_score     = data['away_score']
          @goal_scorer    = OpenStruct.new(data['goal_scorer']) if data['goal_scorer']
          @stoppage_time  = data['stoppage_time'].to_i          if data['stoppage_time']
          @player_out     = OpenStruct.new(data['player_out'])  if data['player_out']
          @player_in      = OpenStruct.new(data['player_in'])   if data['player_in']
          @player         = OpenStruct.new(data['player'])      if data['player'] # red/yellow cards
        end

        def updated_at
          @time
        end

        def minute
          @match_time
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sportradar-api-0.13.4 lib/sportradar/api/soccer/event.rb
sportradar-api-0.13.3 lib/sportradar/api/soccer/event.rb
sportradar-api-0.13.2 lib/sportradar/api/soccer/event.rb
sportradar-api-0.13.1 lib/sportradar/api/soccer/event.rb
sportradar-api-0.13.0 lib/sportradar/api/soccer/event.rb