Class: WhatAWorld::Scraper::ScraperCountry

Inherits:
Object
  • Object
show all
Defined in:
lib/what_a_world/scraper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url_extension) ⇒ ScraperCountry

Returns a new instance of ScraperCountry.



46
47
48
49
50
# File 'lib/what_a_world/scraper.rb', line 46

def initialize(url_extension)
    country_url = URL + url_extension
    html = open(country_url)
    @country_page = Nokogiri::HTML(html)
end

Instance Attribute Details

#country_pageObject

Returns the value of attribute country_page.



44
45
46
# File 'lib/what_a_world/scraper.rb', line 44

def country_page
  @country_page
end

#region=(value) ⇒ Object (writeonly)

Sets the attribute region

Parameters:

  • value

    the value to set the attribute region to.



45
46
47
# File 'lib/what_a_world/scraper.rb', line 45

def region=(value)
  @region = value
end

Instance Method Details

#find_dateObject



52
53
54
# File 'lib/what_a_world/scraper.rb', line 52

def find_date
    self.country_page.css("div.lastMod").text.strip
end

#find_regionObject



55
56
57
58
# File 'lib/what_a_world/scraper.rb', line 55

def find_region
    str = self.country_page.css("div.region1.geos_title").text.strip
    self.region = str.split("  ")[0]
end