Class: SkiMapScraper
- Inherits:
-
Object
- Object
- SkiMapScraper
- Defined in:
- lib/study_the_map/ski_map_scraper.rb
Instance Method Summary collapse
- #area_info ⇒ Object
-
#initialize(area_name) ⇒ SkiMapScraper
constructor
A new instance of SkiMapScraper.
- #map_count ⇒ Object
- #scrape_map_data ⇒ Object
- #scrape_map_ids ⇒ Object
- #scrape_map_years ⇒ Object
Constructor Details
#initialize(area_name) ⇒ SkiMapScraper
Returns a new instance of SkiMapScraper.
3 4 5 |
# File 'lib/study_the_map/ski_map_scraper.rb', line 3 def initialize(area_name) @url = "https://skimap.org/SkiAreas/view/#{LookupIDS.find_ski_area_id(area_name)}.xml" end |
Instance Method Details
#area_info ⇒ Object
7 8 9 |
# File 'lib/study_the_map/ski_map_scraper.rb', line 7 def area_info Nokogiri::XML(open(@url)) end |
#map_count ⇒ Object
39 40 41 |
# File 'lib/study_the_map/ski_map_scraper.rb', line 39 def map_count self.area_info.search("skiMaps").attr('count').text end |
#scrape_map_data ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/study_the_map/ski_map_scraper.rb', line 23 def scrape_map_data self.scrape_map_ids.collect do |id| Nokogiri::XML(open("https://skimap.org/SkiMaps/view/#{id}.xml")) end end |
#scrape_map_ids ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/study_the_map/ski_map_scraper.rb', line 11 def scrape_map_ids id_array = [] self.area_info.search("skiMaps skiMap").each do |map| id_array << map.attr('id') end id_array end |
#scrape_map_years ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/study_the_map/ski_map_scraper.rb', line 31 def scrape_map_years self.scrape_map_data.collect do |map| map.search("yearPublished").text end end |