Sha256: 059f0a0572b893180a80fd602dd60b876a29559e74fb6c6680d1bb9339efd4b3

Contents?: true

Size: 701 Bytes

Versions: 1

Compression:

Stored size: 701 Bytes

Contents

module CalendarDates

  def available?(list, a = today, b = tomorrow)
    vrbo_calendar.available?(a, b, list)
  end

  def all
    prep [today, tomorrow]
  end

  def random
    prep all.shuffle
  end

  def arrival_only
    prep [today]
  end

  def depart_only
    prep [tomorrow]
  end

  def prep(list)
    list.map(&:to_s)
  end

  def today
    @today ||= Date.today
  end

  def tomorrow
    @tomorrow ||= today + 1
  end

  def vrbo_calendar
    @vrbo_calendar ||= begin
      calendar = VRBO::Calendar.new

      def calendar.collect_days_for_month(date)
        dates = date.upto(date.next_month).to_a
        dates.map(&:day).map(&:to_s).take(3)
      end

      calendar
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vrbo-1.1.0 test/support/calendar_dates.rb