Class: EspnScrape

Inherits:
Object
  • Object
show all
Defined in:
lib/espnscrape.rb

Overview

EspnScrape main class

Constant Summary collapse

VERSION =

Gem Version

'0.6.0'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ EspnScrape

initialize



35
36
37
# File 'lib/espnscrape.rb', line 35

def initialize(config = {})
  @format = defaultFormat(config[:format])
end

Class Method Details

.boxscore(game_id, f_mat = nil) ⇒ NbaBoxScore

Returns an NbaBoxScore object

Examples:

EspnScrape.boxscore(493848273)

Parameters:

  • game_id (Integer)

    Boxscore ID

Returns:



44
45
46
47
# File 'lib/espnscrape.rb', line 44

def self.boxscore(game_id, f_mat = nil)
  NbaBoxScore.new(game_id: game_id,
                  format: defaultFormat(f_mat))
end

.player(espn_id) ⇒ NbaPlayer

Return new NbaPlayer object

Examples:

EspnScrape.player(2991473)

Parameters:

  • espn_id (String)

    ESPN Player ID

Returns:



126
127
128
# File 'lib/espnscrape.rb', line 126

def self.player(espn_id)
  NbaPlayer.new espn_id
end

.roster(team_id, options = {}) ⇒ NbaRoster

Returns an NbaRoster object

Examples:

EspnScrape.roster('UTA')

Parameters:

  • team_id (String)

    Team ID

Returns:



63
64
65
66
# File 'lib/espnscrape.rb', line 63

def self.roster(team_id, options = {})
  NbaRoster.new(team_id: team_id,
                format: defaultFormat(options.fetch(:format, nil)))
end

.schedule(team_id, options = {}) ⇒ NbaSchedule

Return an NbaSchedule object

Examples:

EspnScrape.schedule('UTA')            # Schedule for Latest Season Type
EspnScrape.schedule('TOR', s_type: 3) # Playoff Schedule

Parameters:

  • team_id (String)

    Team ID

  • s_type (Int)

    Season Type

Returns:



101
102
103
104
105
106
# File 'lib/espnscrape.rb', line 101

def self.schedule(team_id, options = {})
  NbaSchedule.new team_id: team_id,
                  season_type: options.fetch(:season, ''),
                  format: defaultFormat(options.fetch(:format, nil)),
                  year: options.fetch(:year, nil)
end

.teamList(f_mat = nil) ⇒ [[String]]

Return Array of Team Data

Examples:

EspnScrape.teamList(:to_structs)

Returns:

  • ([[String]])

    NBA Team Data



82
83
84
# File 'lib/espnscrape.rb', line 82

def self.teamList(f_mat = nil)
  NbaTeamList.new(format: defaultFormat(f_mat)).teamList
end

Instance Method Details

#boxscore(game_id, f_mat = nil) ⇒ NbaBoxScore

Returns an NbaBoxScore object

Examples:

es.boxscore(493848273)

Parameters:

  • game_id (Integer)

    Boxscore ID

Returns:



54
55
56
# File 'lib/espnscrape.rb', line 54

def boxscore(game_id, f_mat = nil)
  EspnScrape.boxscore game_id, (f_mat || @format)
end

#player(espn_id) ⇒ NbaPlayer

Return new NbaPlayer object

Examples:

es.player(2991473)

Parameters:

  • espn_id (String)

    ESPN Player ID

Returns:



135
136
137
# File 'lib/espnscrape.rb', line 135

def player(espn_id)
  EspnScrape.player espn_id
end

#roster(team_id, options = {}) ⇒ NbaRoster

Returns an NbaRoster object

Examples:

es.roster('UTA')
es.roster('UTA', format: :to_structs)

Parameters:

  • team_id (String)

    Team ID

Returns:



74
75
76
# File 'lib/espnscrape.rb', line 74

def roster(team_id, options = {})
  EspnScrape.roster team_id, format: (options.fetch(:format, nil) || @format)
end

#schedule(team_id, options = {}) ⇒ NbaSchedule

Return an NbaSchedule object

Examples:

es.schedule('MIA')     # Schedule for Latest Season Type
es.schedule('DET', s_type: 1)  # Preseason Schedule

Parameters:

  • team_id (String)

    Team ID

  • s_type (Int)

    Season Type

Returns:



114
115
116
117
118
119
# File 'lib/espnscrape.rb', line 114

def schedule(team_id, options = {})
  EspnScrape.schedule team_id,
                      s_type: options.fetch(:season, ''),
                      format: (options.fetch(:format, nil) || @format),
                      year: options.fetch(:year, nil)
end

#teamList(f_mat = nil) ⇒ [[String]]

Return Array of Team Data

Examples:

es.teamList(:to_structs)

Returns:

  • ([[String]])

    NBA Team Data



90
91
92
# File 'lib/espnscrape.rb', line 90

def teamList(f_mat = nil)
  EspnScrape.teamList(f_mat || @format)
end