Sha256: 5a90f353c3d05181d6bea9be5c8ae4307a0dbf99b877ae3085579c03389ce9d4

Contents?: true

Size: 682 Bytes

Versions: 2

Compression:

Stored size: 682 Bytes

Contents

# -*- coding: utf-8 -*-
require 'holiday_jp/holiday'
require 'holiday_jp/holidays'

module HolidayJp
  # == Between date
  # === Example:
  #  >> holidays = HolidayJp.between(Date.new(2010, 9, 14), Date.new(2010, 9, 21))
  #  >> holidays.first.name # 敬老の日
  # === parameters
  # * <tt>start</tt>
  # * <tt>last</tt>
  def self.between(start, last)
    HOLIDAYS.find_all do |date, holiday|
      start <= date && date <= last
    end.map(&:last)
  end


  # == Whether the date is holiday or not.
  # === Example:
  # >> HolidayJp.holiday?(Date.new(2011, 9, 19)) # => true
  # === parameter(s)
  # * <tt>date</tt>
  def self.holiday?(date)
    !HOLIDAYS[date].nil?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
holiday_jp-0.3.1 lib/holiday_jp.rb
holiday_jp-0.3.0 lib/holiday_jp.rb