lib/vrbo/calendar.rb in vrbo-0.2.1 vs lib/vrbo/calendar.rb in vrbo-1.0.0

- old
+ new

@@ -24,20 +24,20 @@ def find_available_dates today = Date.today @available_dates = today.upto(today + 365).map { |date| date_if_available(date) }.compact end - alias :find_all_available_dates :find_available_dates - - def calendar_url(protocol = 'http') + def url(protocol = 'http') if id "#{protocol}://www.vrbo.com/#{id}/calendar" else raise ArgumentError, 'You must provide a calendar id' end end + alias :find_all_available_dates :find_available_dates + private def date_if_available(date) m = date.month.to_s days[m] ||= collect_days_for_month(date) @@ -51,19 +51,18 @@ def scrape_table_for(date) calendar.search('.cal-month').at(table_xpath(date)).search('td:not(.strike)') end def calendar - @calendar ||= agent.get(calendar_url) + @calendar ||= agent.get(url) end def agent @agent ||= Mechanize.new end # e.g. March 2014 def table_xpath(date) "//b[contains(text(), '#{date.strftime('%B %Y')}')]/following-sibling::table" end - end end \ No newline at end of file