Class: DailyDealr
Defined Under Namespace
Instance Method Summary collapse
- #cities ⇒ Object
- #deals(city_code) ⇒ Object
-
#initialize(options = {}) ⇒ DailyDealr
constructor
A new instance of DailyDealr.
Constructor Details
#initialize(options = {}) ⇒ DailyDealr
Returns a new instance of DailyDealr.
12 13 14 15 16 |
# File 'lib/dailydealr.rb', line 12 def initialize( = {}) @base_url = "http://api.dailydeal.com/get" @version = "1.0" @format = :json end |
Instance Method Details
#cities ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/dailydealr.rb', line 18 def cities parsed_response = self.class.get("#{@base_url}/cities?format=#{@format}&v=#{@version}").parsed_response raise parsed_response["error"].collect {|e| e["errorMessage"] }.join("\n") if parsed_response["error"] parsed_response["city"].collect { |c| City.new(c) } end |
#deals(city_code) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/dailydealr.rb', line 26 def deals(city_code) parsed_response = self.class.get("#{@base_url}/deals/#{city_code}?format=#{@format}&v=#{@version}").parsed_response raise parsed_response["error"].collect {|e| e["errorMessage"] }.join("\n") if parsed_response["error"] parsed_response["deal"].collect { |d| Deal.new(d) } end |