Class: Celly::Player
- Inherits:
-
Object
- Object
- Celly::Player
- Defined in:
- lib/celly/player.rb
Constant Summary collapse
- BASE_URL =
'https://statsapi.web.nhl.com/api/v1'
Instance Method Summary collapse
- #playoffs_career_stats(player_id) ⇒ Object
- #playoffs_stats_by_year(player_id) ⇒ Object
- #profile(id) ⇒ Object
- #regular_season_career_stats(player_id) ⇒ Object
- #season_stats(player_id, season) ⇒ Object
Instance Method Details
#playoffs_career_stats(player_id) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/celly/player.rb', line 45 def playoffs_career_stats(player_id) end_point = "/people/#{player_id}/stats?stats=careerPlayoffs" uri = URI("#{BASE_URL}#{end_point}") response = Net::HTTP.get_response(uri) if response.code == '200' json_response = JSON.parse(response.body) {status: response.code, message: response., data: json_response["stats"][0]["splits"][0]["stat"]} else {status: response.code, message: response.} end end |
#playoffs_stats_by_year(player_id) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/celly/player.rb', line 58 def playoffs_stats_by_year(player_id) end_point = "/people/#{player_id}/stats?stats=yearByYearPlayoffs" uri = URI("#{BASE_URL}#{end_point}") response = Net::HTTP.get_response(uri) if response.code == '200' json_response = JSON.parse(response.body) {status: response.code, message: response., data: json_response["stats"][0]["splits"]} else {status: response.code, message: response.} end end |
#profile(id) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/celly/player.rb', line 6 def profile(id) end_point = "/people/#{id}" uri = URI("#{BASE_URL}#{end_point}") response = Net::HTTP.get_response(uri) if response.code == '200' json_response = JSON.parse(response.body) {status: response.code, message: response., data: json_response["people"]} else {status: response.code, message: response.} end end |
#regular_season_career_stats(player_id) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/celly/player.rb', line 32 def regular_season_career_stats(player_id) end_point = "/people/#{player_id}/stats?stats=careerRegularSeason" uri = URI("#{BASE_URL}#{end_point}") response = Net::HTTP.get_response(uri) if response.code == '200' json_response = JSON.parse(response.body) {status: response.code, message: response., data: json_response["stats"][0]["splits"][0]["stat"]} else {status: response.code, message: response.} end end |
#season_stats(player_id, season) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/celly/player.rb', line 19 def season_stats(player_id, season) end_point = "/people/#{player_id}/stats?stats=statsSingleSeason&season=#{season}" uri = URI("#{BASE_URL}#{end_point}") response = Net::HTTP.get_response(uri) if response.code == '200' json_response = JSON.parse(response.body) {status: response.code, message: response., data: json_response["stats"][0]["splits"][0]["stat"]} else {status: response.code, message: response.} end end |