Class: OnTheSnow::Resort::Resort

Inherits:
Object
  • Object
show all
Includes:
Elevation, Info, Lifts, Slopes, Snow, Weather
Defined in:
lib/onthesnow/resort/resort.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Weather

#condition, #date, #degree, #degree_in_c, #degree_in_f, #weather

Methods included from Snow

#last_24, #last_48, #last_72, #snow

Methods included from Elevation

#elevation, #height_difference, #peak, #valley

Methods included from Slopes

#advanced_slopes, #beginner_slopes, #expert_slopes, #intermediate_slopes, #slopes

Methods included from Lifts

#double_lifts, #fast_quads_lifts, #fast_sixes_lifts, #lifts, #quad_lifts, #surface_lifts, #total_lifts, #trams_lifts, #triple_lifts

Methods included from Info

#infos, #name, #states, #url

Constructor Details

#initialize(url) ⇒ Resort

Returns a new instance of Resort.



11
12
13
14
# File 'lib/onthesnow/resort/resort.rb', line 11

def initialize(url)
  @url    = url
  @api = OnTheSnow::API.instance
end

Class Method Details

.allObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/onthesnow/resort/resort.rb', line 20

def self.all
  if @resorts
    @resorts
  else
    @resorts = {}
    @resorts_count = 0
    @api = OnTheSnow::API.instance
    @api.states.each_value do |state|
      @api.rss(state["rss"]).items.each do |item|
        url = @api.build_profile_url_from_snow_resort_url(item.guid)
        resort = new(url)
        @resorts[(@resorts_count+=1).to_s] = resort.to_hash 
        #warn "grab #{resort.infos["name"]} => #{resort.inspect}\n" 
      end
    end
    @resorts
  end
end

Instance Method Details

#to_hashObject



16
17
18
# File 'lib/onthesnow/resort/resort.rb', line 16

def to_hash
  @hash ||= {"info" => infos, "elevation" => elevation, "lifts" => lifts, "slopes" => slopes, "snow" => snow, "weather" => weather}
end