Class: Region

Inherits:
Object
  • Object
show all
Defined in:
lib/study_the_map/regions.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(region) ⇒ Region

Returns a new instance of Region.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/study_the_map/regions.rb', line 6

def initialize(region)

  region_data = RegionScraper.new(region)
  @region_info = region_data.region_info
 
  self.region_id = @region_info.search("region").attr('id').text
  

  puts "Here are the ski resorts in #{region}:"

  self.ski_areas = region_data.scrape_ski_areas

end

Instance Attribute Details

#region_idObject

Returns the value of attribute region_id.



4
5
6
# File 'lib/study_the_map/regions.rb', line 4

def region_id
  @region_id
end

#region_infoObject

Returns the value of attribute region_info.



4
5
6
# File 'lib/study_the_map/regions.rb', line 4

def region_info
  @region_info
end

#ski_areasObject

Returns the value of attribute ski_areas.



4
5
6
# File 'lib/study_the_map/regions.rb', line 4

def ski_areas
  @ski_areas
end

Class Method Details

.starts_with(letter) ⇒ Object



20
21
22
23
24
25
# File 'lib/study_the_map/regions.rb', line 20

def self.starts_with(letter)
  # regions that start with
  regions_starts_with_letter = RegionScraper.regions_list.select {|region_name| region_name.start_with?(letter.upcase)}
  regions_starts_with_letter.each.with_index(1) {|region_name, index| puts "#{index}. #{region_name}"}

end

Instance Method Details

#full_listObject



28
29
30
31
32
# File 'lib/study_the_map/regions.rb', line 28

def full_list

  self.ski_areas.each.with_index(1){|area, i| puts "#{i}. #{area}"}

end