Class: Sportradar::Api::Football::GameStats

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/football/game_stats.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) ⇒ GameStats

attr_writer :rushing, :receiving, :punts, :punt_returns, :penalties, :passing, :misc_returns, :kickoffs, :kick_returns, :int_returns, :fumbles, :field_goals, :extra_points, :defense # probably not necessary, but leaving here in case we want it later



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/sportradar/api/football/game_stats.rb', line 9

def initialize(data)
  @response        = data
  @id              = data["id"]
  @name            = data["name"]
  @market          = data["market"]
  @alias           = data["alias"]
  @reference       = data["reference"]
  @efficiency      = data["efficiency"]
  @first_downs     = data["first_downs"]
  @interceptions   = data["interceptions"]
  @touchdowns      = data["touchdowns"]
  @possession_time = data.dig('summary', "possession_time")
  @avg_gain        = data.dig('summary', "avg_gain")
  @safeties        = data.dig('summary', "safeties")
  @turnovers       = data.dig('summary', "turnovers")
  @play_count      = data.dig('summary', "play_count")
  @rush_plays      = data.dig('summary', "rush_plays")
  @total_yards     = data.dig('summary', "total_yards")
  @lost_fumbles    = data.dig('summary', "lost_fumbles")
  @penalty_yards   = data.dig('summary', "penalty_yards")
  @return_yards    = data.dig('summary', "return_yards")
end

Instance Attribute Details

#aliasObject

Returns the value of attribute alias.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def alias
  @alias
end

#avg_gainObject

Returns the value of attribute avg_gain.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def avg_gain
  @avg_gain
end

#efficiencyObject

Returns the value of attribute efficiency.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def efficiency
  @efficiency
end

#first_downsObject

Returns the value of attribute first_downs.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def first_downs
  @first_downs
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def id
  @id
end

#interceptionsObject

Returns the value of attribute interceptions.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def interceptions
  @interceptions
end

#lost_fumblesObject

Returns the value of attribute lost_fumbles.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def lost_fumbles
  @lost_fumbles
end

#marketObject

Returns the value of attribute market.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def market
  @market
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def name
  @name
end

#penalty_yardsObject

Returns the value of attribute penalty_yards.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def penalty_yards
  @penalty_yards
end

#play_countObject

Returns the value of attribute play_count.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def play_count
  @play_count
end

#possession_timeObject

Returns the value of attribute possession_time.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def possession_time
  @possession_time
end

#referenceObject

Returns the value of attribute reference.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def reference
  @reference
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def response
  @response
end

#return_yardsObject

Returns the value of attribute return_yards.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def return_yards
  @return_yards
end

#rush_playsObject

Returns the value of attribute rush_plays.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def rush_plays
  @rush_plays
end

#safetiesObject

Returns the value of attribute safeties.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def safeties
  @safeties
end

#total_yardsObject

Returns the value of attribute total_yards.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def total_yards
  @total_yards
end

#touchdownsObject

Returns the value of attribute touchdowns.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def touchdowns
  @touchdowns
end

#turnoversObject

Returns the value of attribute turnovers.



5
6
7
# File 'lib/sportradar/api/football/game_stats.rb', line 5

def turnovers
  @turnovers
end

Instance Method Details

#defenseObject



129
130
131
132
133
134
# File 'lib/sportradar/api/football/game_stats.rb', line 129

def defense
  @defense ||= if response["defense"]
    response["defense"] = parse_out_hashes response["defense"]
    Sportradar::Api::Football::StatPack::Defense.new(response["defense"])
  end
end

#extra_pointsObject



122
123
124
125
126
127
# File 'lib/sportradar/api/football/game_stats.rb', line 122

def extra_points
  @extra_points ||= if (data = response["extra_points"] || response["extra_point"])
    data = parse_out_hashes data
    Sportradar::Api::Football::StatPack::ExtraPoints.new(data)
  end
end

#field_goalsObject



115
116
117
118
119
120
# File 'lib/sportradar/api/football/game_stats.rb', line 115

def field_goals
  @field_goals ||= if (data = response["field_goals"] || response["field_goal"])
    data = parse_out_hashes data
    Sportradar::Api::Football::StatPack::FieldGoals.new(data)
  end
end

#fumblesObject



108
109
110
111
112
113
# File 'lib/sportradar/api/football/game_stats.rb', line 108

def fumbles
  @fumbles ||= if response["fumbles"]
    response["fumbles"] = parse_out_hashes response["fumbles"]
    Sportradar::Api::Football::StatPack::Fumbles.new(response["fumbles"])
  end
end

#int_returnsObject



101
102
103
104
105
106
# File 'lib/sportradar/api/football/game_stats.rb', line 101

def int_returns
  @int_returns ||= if response["int_returns"]
    response["int_returns"] = parse_out_hashes response["int_returns"]
    Sportradar::Api::Football::StatPack::IntReturns.new(response["int_returns"])
  end
end

#kick_returnsObject



94
95
96
97
98
99
# File 'lib/sportradar/api/football/game_stats.rb', line 94

def kick_returns
  @kick_returns ||= if (data = response["kick_returns"] || response["kick_return"])
    data = parse_out_hashes data
    Sportradar::Api::Football::StatPack::KickReturns.new(data)
  end
end

#kickoffsObject



87
88
89
90
91
92
# File 'lib/sportradar/api/football/game_stats.rb', line 87

def kickoffs
  @kickoffs ||= if response["kickoffs"]
    response["kickoffs"] = parse_out_hashes response["kickoffs"]
    Sportradar::Api::Football::StatPack::Kickoffs.new(response["kickoffs"])
  end
end

#misc_returnsObject



80
81
82
83
84
85
# File 'lib/sportradar/api/football/game_stats.rb', line 80

def misc_returns
  @misc_returns ||= if response["misc_returns"]
    response["misc_returns"] = parse_out_hashes response["misc_returns"]
    Sportradar::Api::Football::StatPack::MiscReturns.new(response["misc_returns"])
  end
end

#passingObject



73
74
75
76
77
78
# File 'lib/sportradar/api/football/game_stats.rb', line 73

def passing
  @passing ||= if response["passing"]
    response["passing"] = parse_out_hashes response["passing"]
    Sportradar::Api::Football::StatPack::Passing.new(response["passing"])
  end
end

#penaltiesObject



66
67
68
69
70
71
# File 'lib/sportradar/api/football/game_stats.rb', line 66

def penalties
  @penalties ||= if (data = response["penalties"] || response["penalty"])
    data = parse_out_hashes data
    Sportradar::Api::Football::StatPack::Penalties.new(data)
  end
end

#punt_returnsObject



59
60
61
62
63
64
# File 'lib/sportradar/api/football/game_stats.rb', line 59

def punt_returns
  @punt_returns ||= if (data = response["punt_returns"] || response["punt_return"])
    data = parse_out_hashes data
    Sportradar::Api::Football::StatPack::PuntReturns.new(data)
  end
end

#puntsObject



52
53
54
55
56
57
# File 'lib/sportradar/api/football/game_stats.rb', line 52

def punts
  @punts ||= if (data = response["punts"] || response["punting"])
    data = parse_out_hashes data
    Sportradar::Api::Football::StatPack::Punts.new(data)
  end
end

#receivingObject



45
46
47
48
49
50
# File 'lib/sportradar/api/football/game_stats.rb', line 45

def receiving
  @receiving ||= if response["receiving"]
    response["receiving"] = parse_out_hashes response["receiving"]
    Sportradar::Api::Football::StatPack::Receiving.new(response["receiving"])
  end
end

#rushingObject

:skip_test_coverage: These are in methods rather than attributes to use them lazily. Each one is tested in it’s respective class



38
39
40
41
42
43
# File 'lib/sportradar/api/football/game_stats.rb', line 38

def rushing
  @rushing ||= if response["rushing"]
    response["rushing"] = parse_out_hashes response["rushing"]
    Sportradar::Api::Football::StatPack::Rushing.new(response["rushing"])
  end
end