class Barcade::Scraper

Constants

BASE_URI

Attributes

date_slug[RW]

Public Class Methods

new(date) click to toggle source
# File lib/barcade/scraper.rb, line 9
def initialize(date)
  @date_slug = date.strftime('%Y/%m/%d/')
end

Public Instance Methods

blog_post() click to toggle source
# File lib/barcade/scraper.rb, line 18
def blog_post
  agent = Mechanize.new

  begin
    post = agent.get("#{BASE_URI}#{self.date_slug}")
  rescue Mechanize::ResponseCodeError => e
    puts "Today's tap hasn't been posted yet. Try the --yesterday flag."
    exit
  end
end
tap() click to toggle source
# File lib/barcade/scraper.rb, line 13
def tap
  body = blog_post.search('section.entry > p').text
  body.split(/\n/)
end