Sha256: 28bc3a55ac9750d6a1b57d2a8bbfccc556c5cb7e1f95be64c8675d505a95f5b6
Contents?: true
Size: 563 Bytes
Versions: 2
Compression:
Stored size: 563 Bytes
Contents
module VRBO class Availability attr_accessor :first, :duration, :errors def initialize(dates = []) if dates.try(:any?) self.first = Date.parse(dates.shift) self.duration = self.calc_duration(dates) self.errors = [] else self.first = Date.today self.duration = 1 self.errors = %w[Maybe... But likely there was an error] end end def calc_duration(dates) 1 + dates.each_with_index.sum { |the_date, i| Date.parse(the_date) - (first + i.days) == 1 ? 1 : 0 } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vrbo-0.0.5 | lib/vrbo/availability.rb |
vrbo-0.0.4 | lib/vrbo/availability.rb |