Class: Echelon::Disneyland::CaliforniaAdventure
- Defined in:
- lib/echelon/parks/disneyland/california_adventure.rb
Instance Attribute Summary collapse
-
#json_data ⇒ Object
readonly
Returns the value of attribute json_data.
Instance Method Summary collapse
-
#initialize ⇒ CaliforniaAdventure
constructor
A new instance of CaliforniaAdventure.
- #ride_list ⇒ Object
Methods inherited from Park
#find_by_id, #find_by_name, #rides
Constructor Details
#initialize ⇒ CaliforniaAdventure
Returns a new instance of CaliforniaAdventure.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/echelon/parks/disneyland/california_adventure.rb', line 14 def initialize # fetch the json feed url = 'http://dparks.uiemedia.net/dmm_v2/jsondata/JsonUpdateData?version=14&p=336894' resp = Net::HTTP.get_response(URI.parse(url)) data = resp.body # were only interested in the ride data, throw everything else away json_data = JSON.parse(data) ride_data = json_data['attractions']['homeLabels'] queue_data = json_data['attractions']['homeValues'].map(&:to_i) @json_data = ride_data.each_with_index.inject({}) { |a, e| a[e.first.gsub("\302\240", '')] = queue_data[e.last]; a } end |
Instance Attribute Details
#json_data ⇒ Object (readonly)
Returns the value of attribute json_data.
8 9 10 |
# File 'lib/echelon/parks/disneyland/california_adventure.rb', line 8 def json_data @json_data end |
Instance Method Details
#ride_list ⇒ Object
10 11 12 |
# File 'lib/echelon/parks/disneyland/california_adventure.rb', line 10 def ride_list json_data.keys.inject({}) { |a, e| a[e] = e; a } end |