Last active
August 29, 2015 13:55
-
-
Save june29/8709992 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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("#{曜日}曜日?") { self.wday == index } | |
} | |
end | |
明日 = Date.today + 1 | |
targets = [] | |
targets << "可燃ごみ" if 明日.火曜日? or 明日.金曜日? | |
targets << "資源ごみ" if 明日.木曜日? | |
targets << "不燃ごみ" if 明日.水曜日? and (明日.第1? or 明日.第3?) | |
message = | |
if targets.empty? | |
"明日に回収されるごみはありません。" | |
else | |
"明日は%sの日です。" % targets.map { |target| "「#{target}」" }.join | |
end | |
puts message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment