class Greenmonster::DaySpider
Attributes
date[R]
sport_code[R]
Public Class Methods
new(date:, sport_code: "mlb")
click to toggle source
# File lib/greenmonster/day_spider.rb, line 3 def initialize(date:, sport_code: "mlb") @date = date @sport_code = sport_code end
Public Instance Methods
pull()
click to toggle source
# File lib/greenmonster/day_spider.rb, line 8 def pull game_ids_for_date.each do |game_id| Greenmonster::GameSpider. new(sport_code: sport_code, game_id: game_id). pull end end
Private Instance Methods
date_path()
click to toggle source
# File lib/greenmonster/day_spider.rb, line 22 def date_path "#{sport_code}/year_#{year}/month_#{month}/day_#{day}" end
day()
click to toggle source
# File lib/greenmonster/day_spider.rb, line 57 def day date.strftime("%d") end
fetch_game_list()
click to toggle source
# File lib/greenmonster/day_spider.rb, line 26 def fetch_game_list HTTParty. get("#{Greenmonster::REMOTE_DATA_ROOT}/#{date_path}"). response. body end
game_ids_for_date()
click to toggle source
# File lib/greenmonster/day_spider.rb, line 43 def game_ids_for_date game_links_for_date.map do |link| link.text.strip.gsub("/", "") end end
game_links_for_date()
click to toggle source
# File lib/greenmonster/day_spider.rb, line 37 def game_links_for_date html_links.select do |link| link.text.strip[0..3] == "gid_" end end
html_links()
click to toggle source
# File lib/greenmonster/day_spider.rb, line 33 def html_links Nokogiri::HTML(fetch_game_list).search("a") end
month()
click to toggle source
# File lib/greenmonster/day_spider.rb, line 53 def month date.strftime("%m") end
year()
click to toggle source
# File lib/greenmonster/day_spider.rb, line 49 def year date.strftime("%Y") end