Skip to content

Commit

Permalink
Merge branch 'master' of github.com:tropo/tropo-samples
Browse files Browse the repository at this point in the history
  • Loading branch information
akalsey committed May 27, 2011
2 parents f4994f0 + 3a2878f commit 345e640
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
14 changes: 0 additions & 14 deletions ruby/restaurantfinder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,28 @@
:onBadChoice => lambda { say 'Invalid entry, please try again.' },
:onTimeout => lambda { say 'Timeout, please try again.' },
:onChoice => lambda { |search_choice|

#Set the URI and our YQL select statement, then encode as a URI
yahoo_url = 'http://query.yahooapis.com/v1/public/yql?format=json&q='
query = "select * from local.search where zip=#{zip_code_choice.value} and query='#{search_choice.value}'"
url = URI.encode(yahoo_url + query)

#Fetch the JSON from the YQL API and convert the resulting
#JSON data to a Ruby hash
<<<<<<< HEAD:ruby/restaurantfinder.rb
restaurant = JSON.parse(open(url).read)

#Speak back the results
if restaurant
restaurant["query"]["results"]["Result"].each do |restaurant|
=======
restaurants = JSON.parse(open(url).read)

#Speak back the results
if restaurants
restaurants["query"]["results"]["Result"].each do |restaurant|
>>>>>>> d4860197159bbbde06c83499a8908d35eebc6454:ruby/restarauntfinder.rb
say 'The phone number for ' + restaurant["Title"] + ' in ' + restaurant["City"] +
' is ' + restaurant["Phone"]
end
else
<<<<<<< HEAD:ruby/restaurantfinder.rb
say 'I am sorry, an error occurred while fetching restaurant in your area'
=======
say 'I am sorry, an error occurred while fetching restaurants in your area'
>>>>>>> d4860197159bbbde06c83499a8908d35eebc6454:ruby/restarauntfinder.rb
end
}
}
ask 'Say the type of restaurant you would like to search for.', search_options
}
}

ask 'Enter or say your ZIP code to find a restaurant in your area.', zipcode_options
say 'Thats all. Goodbye.'
2 changes: 1 addition & 1 deletion samples.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<p style='font-size:11px;'>The application uses the phone number to determine the timezone, and does the time and date calculations for you. </p>
]]>
</application>
<application name="Ruby - Yahoo Restaurant Search" type="Ruby" url="https://github.com/voxeo/tropo-samples/raw/master/ruby/restarauntfinder.rb" clone="true">
<application name="Ruby - Yahoo Restaurant Search" type="Ruby" url="https://github.com/tropo/tropo-samples/raw/master/ruby/restaurantfinder.rb" clone="true">
<![CDATA[
<p style='font-size:11px;'>Uses YQL to find out some data on local restaurants! </p>
]]>
Expand Down

0 comments on commit 345e640

Please sign in to comment.