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



133
134
135
136
137
138
# File 'lib/sportradar/api/football/game_stats.rb', line 133

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

#dig(*args) ⇒ Object



32
33
34
# File 'lib/sportradar/api/football/game_stats.rb', line 32

def dig(*args)
  args.inject(self) { |memo, arg| memo.public_send(arg) }
end

#extra_pointsObject



126
127
128
129
130
131
# File 'lib/sportradar/api/football/game_stats.rb', line 126

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



119
120
121
122
123
124
# File 'lib/sportradar/api/football/game_stats.rb', line 119

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



112
113
114
115
116
117
# File 'lib/sportradar/api/football/game_stats.rb', line 112

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



105
106
107
108
109
110
# File 'lib/sportradar/api/football/game_stats.rb', line 105

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



98
99
100
101
102
103
# File 'lib/sportradar/api/football/game_stats.rb', line 98

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



91
92
93
94
95
96
# File 'lib/sportradar/api/football/game_stats.rb', line 91

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



84
85
86
87
88
89
# File 'lib/sportradar/api/football/game_stats.rb', line 84

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



77
78
79
80
81
82
# File 'lib/sportradar/api/football/game_stats.rb', line 77

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

#penaltiesObject



70
71
72
73
74
75
# File 'lib/sportradar/api/football/game_stats.rb', line 70

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



63
64
65
66
67
68
# File 'lib/sportradar/api/football/game_stats.rb', line 63

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



56
57
58
59
60
61
# File 'lib/sportradar/api/football/game_stats.rb', line 56

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

#receivingObject



49
50
51
52
53
54
# File 'lib/sportradar/api/football/game_stats.rb', line 49

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



42
43
44
45
46
47
# File 'lib/sportradar/api/football/game_stats.rb', line 42

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