Class: Pumi::DataSource::Wikipedia
- Inherits:
-
Object
- Object
- Pumi::DataSource::Wikipedia
- Defined in:
- lib/pumi/data_source/wikipedia.rb
Defined Under Namespace
Classes: CambodianCommunesScraper, CambodianDistrictsScraper, CambodianProvincesScraper, ScraperResult, WebScraper
Instance Attribute Summary collapse
-
#data_file ⇒ Object
readonly
Returns the value of attribute data_file.
-
#scraper ⇒ Object
readonly
Returns the value of attribute scraper.
Instance Method Summary collapse
-
#initialize(data_file:, scraper:) ⇒ Wikipedia
constructor
A new instance of Wikipedia.
- #load_data!(output_dir: "data") ⇒ Object
Constructor Details
#initialize(data_file:, scraper:) ⇒ Wikipedia
Returns a new instance of Wikipedia.
9 10 11 12 |
# File 'lib/pumi/data_source/wikipedia.rb', line 9 def initialize(data_file:, scraper:) @data_file = data_file @scraper = scraper end |
Instance Attribute Details
#data_file ⇒ Object (readonly)
Returns the value of attribute data_file.
7 8 9 |
# File 'lib/pumi/data_source/wikipedia.rb', line 7 def data_file @data_file end |
#scraper ⇒ Object (readonly)
Returns the value of attribute scraper.
7 8 9 |
# File 'lib/pumi/data_source/wikipedia.rb', line 7 def scraper @scraper end |
Instance Method Details
#load_data!(output_dir: "data") ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pumi/data_source/wikipedia.rb', line 14 def load_data!(output_dir: "data") data.each do |code, attributes| location_data = scraped_data.find { |location| location.code == code } next unless location_data if location_data.wikipedia attributes["links"] ||= {} attributes["links"]["wikipedia"] = location_data.wikipedia end attributes["name"]["ungegn"] = location_data.name_ungegn if location_data.name_ungegn end write_data!(output_dir) end |