Class: Sportradar::Api::Soccer::Event

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/soccer/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Data

#all_attributes, #attributes, #create_data, #parse_into_array, #parse_into_array_with_options, #parse_out_hashes, #structure_links, #update_data

Constructor Details

#initialize(data, **opts) ⇒ Event

Returns a new instance of Event.



7
8
9
10
11
12
# File 'lib/sportradar/api/soccer/event.rb', line 7

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

  update(data, **opts)
end

Instance Attribute Details

#away_scoreObject (readonly)

Returns the value of attribute away_score.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def away_score
  @away_score
end

#commentariesObject (readonly)

Returns the value of attribute commentaries.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def commentaries
  @commentaries
end

#goal_scorerObject (readonly)

Returns the value of attribute goal_scorer.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def goal_scorer
  @goal_scorer
end

#home_scoreObject (readonly)

Returns the value of attribute home_score.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def home_score
  @home_score
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def id
  @id
end

#match_timeObject (readonly)

Returns the value of attribute match_time.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def match_time
  @match_time
end

#outcomeObject (readonly)

Returns the value of attribute outcome.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def outcome
  @outcome
end

#periodObject (readonly)

Returns the value of attribute period.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def period
  @period
end

#period_nameObject (readonly)

Returns the value of attribute period_name.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def period_name
  @period_name
end

#period_typeObject (readonly)

Returns the value of attribute period_type.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def period_type
  @period_type
end

#playerObject (readonly)

Returns the value of attribute player.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def player
  @player
end

#player_inObject (readonly)

Returns the value of attribute player_in.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def player_in
  @player_in
end

#player_outObject (readonly)

Returns the value of attribute player_out.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def player_out
  @player_out
end

#stoppage_timeObject (readonly)

Returns the value of attribute stoppage_time.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def stoppage_time
  @stoppage_time
end

#teamObject (readonly)

Returns the value of attribute team.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def team
  @team
end

#timeObject (readonly)

Returns the value of attribute time.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def time
  @time
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def type
  @type
end

#xObject (readonly)

Returns the value of attribute x.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



5
6
7
# File 'lib/sportradar/api/soccer/event.rb', line 5

def y
  @y
end

Instance Method Details

#minuteObject



39
40
41
# File 'lib/sportradar/api/soccer/event.rb', line 39

def minute
  @match_time
end

#update(data, **opts) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sportradar/api/soccer/event.rb', line 14

def update(data, **opts)
  @type           = data['type']                        if data['type']
  @time           = Time.parse(data['time'])            if data['time']
  @period         = data['period']                      if data['period']
  @period_type    = data['period_type']                 if data['period_type']
  @period_name    = data['period_name']                 if data['period_name']
  @match_time     = data['match_time']                  if data['match_time']
  @team           = data['team']                        if data['team']
  @x              = data['x']                           if data['x']
  @y              = data['y']                           if data['y']
  @outcome        = data['outcome']                     if data['outcome']
  @home_score     = data['home_score']                  if data['home_score']
  @away_score     = data['away_score']                  if data['away_score']
  @commentaries   = data['commentaries']                if data['commentaries']
  @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

#updatedObject



35
36
37
# File 'lib/sportradar/api/soccer/event.rb', line 35

def updated
  @time
end