class LinkScraper

Scrapes links and feeds them to PostScraper

Attributes

base_url[R]
url[R]

Public Class Methods

new(url, base_url) click to toggle source
# File lib/craigslister/link_scraper.rb, line 3
def initialize(url, base_url)
  @url = url
  @base_url = base_url
end

Public Instance Methods

posts() click to toggle source
# File lib/craigslister/link_scraper.rb, line 12
def posts
  links.flat_map { |link| post_from(link) }
end

Private Instance Methods

page_from(url) click to toggle source
# File lib/craigslister/link_scraper.rb, line 20
def page_from(url)
  Nokogiri::HTML(open(url))
end
post_from(link) click to toggle source
# File lib/craigslister/link_scraper.rb, line 24
def post_from(link)
  PostScraper.new(page_from(link), link).new_post
end