class CanadianMergers::Scrape

Scraper class

Attributes

month[RW]
year[RW]

Public Class Methods

new(year, month) click to toggle source
# File lib/canadian_mergers/scrape.rb, line 5
def initialize(year, month)
  @year = year
  @month = month
end

Public Instance Methods

get_page() click to toggle source
# File lib/canadian_mergers/scrape.rb, line 10
def get_page
  Nokogiri::HTML(open('http://www.competitionbureau.gc.ca/eic/site/cb-bc.nsf/eng/02435.html'))
end
table_data() click to toggle source
# File lib/canadian_mergers/scrape.rb, line 14
def table_data
  get_page.css("details#details-panel#{@year}-#{@month}").each do |table|
    table.css('tbody tr').each do |tag|
      data = tag.css('td').collect(&:text)
      CanadianMergers::Merger.create(data[0], data[1], data[2])
    end
  end
end