Permalink
Browse files

refine google api error message

  • Loading branch information...
1 parent 8fe2ce9 commit 3eaa6259c0b27f062ebcf71bfaac11cbf8324224 @melborne committed Dec 18, 2010
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/gcalendar.rb
View
7 lib/gcalendar.rb
@@ -21,14 +21,15 @@ def get_holidays(country)
open URL(country) + PARAM(*build_date_range)
rescue => e
STDERR.puts "Failed to retrieve Holiday data by Google Calendar Data API. #{e}"
+ STDERR.puts "Acceptable codes are: #{COUNTRY_ID().keys.join(" ")}"
end
def URL(country)
"http://www.google.com/calendar/feeds/" +
- CGI.escape("#{COUNTRY_ID(country)}") + "/public/full-noattendees?"
+ CGI.escape("#{COUNTRY_ID()[country]}") + "/public/full-noattendees?"
end
- def COUNTRY_ID(country)
+ def COUNTRY_ID
base1 = "@holiday.calendar.google.com"
base2 = "#holiday@group.v.calendar.google.com"
{
@@ -43,7 +44,7 @@ def COUNTRY_ID(country)
kr: "en.south_korea#{base2}",
tw: "en.taiwan#{base2}",
gb: "en.uk#{base2}"
- }[country]
+ }
end
def PARAM(sd, ed)

0 comments on commit 3eaa625

Please sign in to comment.