Sha256: 86740a256d4c3b7bcacd446c6d38eb7d3972336076c8f5620cc78cf9983f779d
Contents?: true
Size: 619 Bytes
Versions: 3
Compression:
Stored size: 619 Bytes
Contents
module VRBO class Availability attr_reader :start_at, :dates # @param [Array] dates list of date strings def initialize(dates = nil) @dates = Array(dates) if @dates.any? @start_at = Date.parse(@dates.shift) else @start_at = Date.today end end # @note assumes @dates are in ascending order def duration i = -1 count = 1 dates.each do |the_date| diff = Date.parse(the_date) - (start_at + (i += 1)) if diff.to_i == 1 count += 1 else break end end count end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vrbo-2.1.1 | lib/vrbo/availability.rb |
vrbo-2.1.0 | lib/vrbo/availability.rb |
vrbo-2.0.1 | lib/vrbo/availability.rb |