Skip to content

Instantly share code, notes, and snippets.

@june29
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save june29/8707810 to your computer and use it in GitHub Desktop.
Save june29/8707810 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
require "date"
class Date
(1..5).each { |n|
define_method("第#{n}?") { (self.day.to_f / 7.to_f).ceil == n }
}
%w(日 月 火 水 木 金 土).each_with_index { |曜日, index|
define_method("#{曜日}曜日?") { index == self.wday }
}
end
今日 = Date.today
今日.木曜日?
今日.第3?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment