class Greenmonster::GameSpider
Attributes
date[R]
game_id[R]
game_number[R]
sport_code[R]
Public Class Methods
new(game_id:, sport_code: "mlb")
click to toggle source
# File lib/greenmonster/game_spider.rb, line 3 def initialize(game_id:, sport_code: "mlb") @game_id = game_id @sport_code = sport_code end
Public Instance Methods
pull()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 8 def pull make_folder download_xml end
Private Instance Methods
date_segments()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 84 def date_segments @date_segments ||= game_id.split("_") end
day()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 96 def day @day ||= date_segments[3] end
download_all_innings_as_one_file()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 56 def download_all_innings_as_one_file Greenmonster::FileDownloader. new(game_path: game_path, file_name: "inning/inning_all.xml"). pull end
download_boxscore()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 36 def download_boxscore Greenmonster::FileDownloader. new(game_path: game_path, file_name: "boxscore.xml"). pull end
download_each_inning_file()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 62 def download_each_inning_file Greenmonster::InningsDownloader.new(game_path: game_path).pull end
download_hit_locations()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 42 def download_hit_locations Greenmonster::FileDownloader. new(game_path: game_path, file_name: "inning/inning_hit.xml"). pull end
download_innings()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 48 def download_innings if year.to_i >= 2008 download_all_innings_as_one_file else download_each_inning_file end end
download_linescore()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 66 def download_linescore Greenmonster::FileDownloader. new(game_path: game_path, file_name: "linescore.xml"). pull end
download_players()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 72 def download_players Greenmonster::FileDownloader. new(game_path: game_path, file_name: "players.xml"). pull end
download_xml()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 24 def download_xml download_innings download_hit_locations download_boxscore download_linescore download_players end
game_path()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 32 def game_path "#{sport_code}/year_#{year}/month_#{month}/day_#{day}/#{game_id}" end
make_folder()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 19 def make_folder FileUtils. mkdir_p("#{Greenmonster.local_data_location}/games/#{game_path}/inning") end
month()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 92 def month @month ||= date_segments[2] end
year()
click to toggle source
# File lib/greenmonster/game_spider.rb, line 88 def year @year ||= date_segments[1] end