month.rb 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +7 -0
  2. data/lib/Array/extract_optionsX.rb +14 -0
  3. data/lib/Date/to_month.rb +12 -0
  4. data/lib/Month/Constants.rb +31 -0
  5. data/lib/Month/VERSION.rb +6 -0
  6. data/lib/Month/_comparator.rb +18 -0
  7. data/lib/Month/begin_date.rb +13 -0
  8. data/lib/Month/beginning.rb +13 -0
  9. data/lib/Month/beginning_of_month.rb +13 -0
  10. data/lib/Month/beginning_of_the_month.rb +13 -0
  11. data/lib/Month/cdate.rb +13 -0
  12. data/lib/Month/cdates.rb +13 -0
  13. data/lib/Month/date.rb +13 -0
  14. data/lib/Month/dates.rb +13 -0
  15. data/lib/Month/day.rb +12 -0
  16. data/lib/Month/day_long.rb +12 -0
  17. data/lib/Month/day_short.rb +12 -0
  18. data/lib/Month/day_shortest.rb +12 -0
  19. data/lib/Month/days.rb +13 -0
  20. data/lib/Month/days_in_month.rb +10 -0
  21. data/lib/Month/days_in_the_month.rb +10 -0
  22. data/lib/Month/each_day.rb +13 -0
  23. data/lib/Month/end.rb +13 -0
  24. data/lib/Month/end_date.rb +13 -0
  25. data/lib/Month/end_of_month.rb +13 -0
  26. data/lib/Month/end_of_the_month.rb +13 -0
  27. data/lib/Month/eqlQ.rb +11 -0
  28. data/lib/Month/finish.rb +13 -0
  29. data/lib/Month/finish_date.rb +13 -0
  30. data/lib/Month/finish_of_month.rb +13 -0
  31. data/lib/Month/finish_of_the_month.rb +13 -0
  32. data/lib/Month/hash.rb +12 -0
  33. data/lib/Month/initialize.rb +27 -0
  34. data/lib/Month/last.rb +13 -0
  35. data/lib/Month/last_month.rb +13 -0
  36. data/lib/Month/last_year.rb +13 -0
  37. data/lib/Month/method_missing.rb +21 -0
  38. data/lib/Month/minus.rb +20 -0
  39. data/lib/Month/next.rb +13 -0
  40. data/lib/Month/next_month.rb +13 -0
  41. data/lib/Month/next_year.rb +13 -0
  42. data/lib/Month/plus.rb +16 -0
  43. data/lib/Month/prev.rb +13 -0
  44. data/lib/Month/prev_month.rb +13 -0
  45. data/lib/Month/previous.rb +13 -0
  46. data/lib/Month/previous_month.rb +13 -0
  47. data/lib/Month/prior.rb +12 -0
  48. data/lib/Month/prior_month.rb +13 -0
  49. data/lib/Month/self.begin_date.rb +23 -0
  50. data/lib/Month/self.beginning.rb +12 -0
  51. data/lib/Month/self.beginning_of_month.rb +12 -0
  52. data/lib/Month/self.beginning_of_the_month.rb +12 -0
  53. data/lib/Month/self.cdate.rb +36 -0
  54. data/lib/Month/self.cdates.rb +54 -0
  55. data/lib/Month/self.date.rb +36 -0
  56. data/lib/Month/self.dates.rb +54 -0
  57. data/lib/Month/self.day.rb +20 -0
  58. data/lib/Month/self.day_long.rb +12 -0
  59. data/lib/Month/self.day_short.rb +20 -0
  60. data/lib/Month/self.day_shortest.rb +20 -0
  61. data/lib/Month/self.days.rb +31 -0
  62. data/lib/Month/self.days_in_month.rb +12 -0
  63. data/lib/Month/self.days_in_the_month.rb +12 -0
  64. data/lib/Month/self.end.rb +12 -0
  65. data/lib/Month/self.end_date.rb +24 -0
  66. data/lib/Month/self.end_of_month.rb +12 -0
  67. data/lib/Month/self.end_of_the_month.rb +12 -0
  68. data/lib/Month/self.finish.rb +12 -0
  69. data/lib/Month/self.finish_date.rb +12 -0
  70. data/lib/Month/self.finish_of_month.rb +12 -0
  71. data/lib/Month/self.finish_of_the_month.rb +12 -0
  72. data/lib/Month/self.from_date.rb +14 -0
  73. data/lib/Month/self.last.rb +12 -0
  74. data/lib/Month/self.last_month.rb +12 -0
  75. data/lib/Month/self.last_year.rb +14 -0
  76. data/lib/Month/self.method_missing.rb +20 -0
  77. data/lib/Month/self.next.rb +28 -0
  78. data/lib/Month/self.next_month.rb +12 -0
  79. data/lib/Month/self.next_year.rb +14 -0
  80. data/lib/Month/self.now.rb +12 -0
  81. data/lib/Month/self.of.rb +37 -0
  82. data/lib/Month/self.prev.rb +28 -0
  83. data/lib/Month/self.prev_month.rb +12 -0
  84. data/lib/Month/self.previous.rb +12 -0
  85. data/lib/Month/self.previous_month.rb +12 -0
  86. data/lib/Month/self.prior.rb +12 -0
  87. data/lib/Month/self.prior_month.rb +12 -0
  88. data/lib/Month/self.start.rb +12 -0
  89. data/lib/Month/self.start_date.rb +12 -0
  90. data/lib/Month/self.start_of_month.rb +12 -0
  91. data/lib/Month/self.start_of_the_month.rb +12 -0
  92. data/lib/Month/self.succ.rb +12 -0
  93. data/lib/Month/self.succ_month.rb +12 -0
  94. data/lib/Month/self.successor.rb +12 -0
  95. data/lib/Month/self.successor_month.rb +12 -0
  96. data/lib/Month/self.this.rb +15 -0
  97. data/lib/Month/self.to_i.rb +13 -0
  98. data/lib/Month/self.to_long.rb +20 -0
  99. data/lib/Month/self.to_num.rb +20 -0
  100. data/lib/Month/self.to_number.rb +12 -0
  101. data/lib/Month/self.to_short.rb +20 -0
  102. data/lib/Month/self.today.rb +12 -0
  103. data/lib/Month/self.wday.rb +20 -0
  104. data/lib/Month/start.rb +13 -0
  105. data/lib/Month/start_date.rb +13 -0
  106. data/lib/Month/start_of_month.rb +13 -0
  107. data/lib/Month/start_of_the_month.rb +13 -0
  108. data/lib/Month/succ.rb +13 -0
  109. data/lib/Month/succ_month.rb +13 -0
  110. data/lib/Month/successor.rb +13 -0
  111. data/lib/Month/successor_month.rb +13 -0
  112. data/lib/Month/to_date.rb +13 -0
  113. data/lib/Month/to_i.rb +13 -0
  114. data/lib/Month/to_long.rb +13 -0
  115. data/lib/Month/to_num.rb +13 -0
  116. data/lib/Month/to_number.rb +13 -0
  117. data/lib/Month/to_s.rb +18 -0
  118. data/lib/Month/to_short.rb +13 -0
  119. data/lib/Month.rb +11 -0
  120. metadata +178 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ce3ea0d18a09b473fd683d198aa9fd6f6659cf481b4b8675794d28a486c68443
4
+ data.tar.gz: c5d6a37c5b8e13e7982aa39d2722264adc03cb1eda1fe8bb3f36c783f154fd14
5
+ SHA512:
6
+ metadata.gz: ce09f0feae95b3d85e5a35ffcf56d3f2ddb4c96a91d822aeed0d43150ae525ee5a89ab16ae248c6a720e3fd0ff9c93887257850e178ec143f106d9bff203fe82
7
+ data.tar.gz: '083f31fbbbfe7301bce3985d09409ce56a0857650c0d2ed96974b08d5226e855f80b4690b7da2b4daca0f0fa1d3cc67d06bd76ef3d9e25555a83211fee824bf2'
@@ -0,0 +1,14 @@
1
+ # Array#extract_options!
2
+
3
+ # 20090123
4
+ # 0.0.0
5
+
6
+ # History: Stolen wholesale from ActiveSupport.
7
+
8
+ class Array
9
+
10
+ def extract_options!
11
+ last.is_a?(::Hash) ? pop : {}
12
+ end
13
+
14
+ end
@@ -0,0 +1,12 @@
1
+ # Date/to_month.rb
2
+ # Date#to_month
3
+
4
+ require 'Month/initialize'
5
+
6
+ class Date
7
+
8
+ def to_month
9
+ Month.new(self.year, self.month)
10
+ end
11
+
12
+ end
@@ -0,0 +1,31 @@
1
+ # Month/Constants.rb
2
+ # Month::Constants
3
+
4
+ require 'date'
5
+
6
+ class Month
7
+ module Constants
8
+ MONTH_NAMES_LONG = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] unless defined?(MONTH_NAMES_LONG)
9
+ MONTH_NAMES_SHORT = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] unless defined?(MONTH_NAMES_SHORT)
10
+ MONTH_NUMBERS = 1..12 unless defined?(MONTH_NUMBERS)
11
+ MONTH_NUMBERS_AS_STRINGS = '1'..'12' unless defined?(MONTH_NUMBERS_AS_STRINGS)
12
+
13
+ MONTH_DAYS = [31, Proc.new{|year| Date.leap?(year) ? 29 : 28}, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] unless defined?(MONTH_DAYS)
14
+
15
+ MONTH_DAY_NUMBERS = 1..31 unless defined?(MONTH_DAY_NUMBERS)
16
+
17
+ ISO_8601_WEEK_DAY_NAMES_LONG = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] unless defined?(ISO_8601_WEEK_DAY_NAMES_LONG)
18
+ ISO_8601_WEEK_DAY_NAMES_SHORT = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] unless defined?(ISO_8601_WEEK_DAY_NAMES_SHORT)
19
+ ISO_8601_WEEK_DAY_NAMES_SHORTEST = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'] unless defined?(ISO_8601_WEEK_DAY_NAMES_SHORTEST)
20
+ ISO_8601_WEEK_DAY_NUMBERS = 1..7 unless defined?(ISO_8601_WEEK_DAY_NUMBERS)
21
+ ISO_8601_WEEK_DAY_NUMBERS_AS_STRINGS = '1'..'7' unless defined?(ISO_8601_WEEK_DAY_NUMBERS_AS_STRINGS)
22
+
23
+ WEEK_DAY_NAMES_LONG = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] unless defined?(WEEK_DAY_NAMES_LONG)
24
+ WEEK_DAY_NAMES_SHORT = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] unless defined?(WEEK_DAY_NAMES_SHORT)
25
+ WEEK_DAY_NAMES_SHORTEST = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'] unless defined?(WEEK_DAY_NAMES_SHORTEST)
26
+ WEEK_DAY_NUMBERS = 0..6 unless defined?(WEEK_DAY_NUMBERS)
27
+ WEEK_DAY_NUMBERS_AS_STRINGS = '0'..'6' unless defined?(WEEK_DAY_NUMBERS_AS_STRINGS)
28
+ end
29
+ end
30
+
31
+ Month.extend(Month::Constants)
@@ -0,0 +1,6 @@
1
+ # Month/VERSION.rb
2
+ # Month::VERSION
3
+
4
+ class Month
5
+ VERSION = '0.10.0' unless defined?(VERSION)
6
+ end
@@ -0,0 +1,18 @@
1
+ # Month/_comparator.rb
2
+ # Month#<=>
3
+
4
+ require 'Month/initialize'
5
+
6
+ class Month
7
+
8
+ include Comparable
9
+
10
+ def <=>(other_month)
11
+ if year == other_month.year
12
+ month <=> other_month.month
13
+ else
14
+ year <=> other_month.year
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,13 @@
1
+ # Month/begin_date.rb
2
+ # Month#begin_date
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.begin_date'
6
+
7
+ class Month
8
+
9
+ def begin_date
10
+ Month.begin_date(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/beginning.rb
2
+ # Month#beginning
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.beginning'
6
+
7
+ class Month
8
+
9
+ def beginning
10
+ Month.beginning(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/beginning_of_month.rb
2
+ # Month#beginning_of_month
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.beginning_of_month'
6
+
7
+ class Month
8
+
9
+ def beginning_of_month
10
+ Month.beginning_of_month(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/beginning_of_the_month.rb
2
+ # Month#beginning_of_the_month
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.beginning_of_the_month'
6
+
7
+ class Month
8
+
9
+ def beginning_of_the_month
10
+ Month.beginning_of_the_month(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/cdate.rb
2
+ # Month#cdate
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.cdate'
6
+
7
+ class Month
8
+
9
+ def cdate(which_day, day)
10
+ Month.cdate(which_day, day, year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/cdates.rb
2
+ # Month#cdates
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.cdates'
6
+
7
+ class Month
8
+
9
+ def cdates(day = nil)
10
+ Month.cdates(year, month, :day => day)
11
+ end
12
+
13
+ end
data/lib/Month/date.rb ADDED
@@ -0,0 +1,13 @@
1
+ # Month/date.rb
2
+ # Month#date
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.date'
6
+
7
+ class Month
8
+
9
+ def date(which_day, day)
10
+ Month.date(which_day, day, year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/dates.rb
2
+ # Month#dates
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.dates'
6
+
7
+ class Month
8
+
9
+ def dates(day = nil)
10
+ Month.dates(year, month, :day => day)
11
+ end
12
+
13
+ end
data/lib/Month/day.rb ADDED
@@ -0,0 +1,12 @@
1
+ # Month/day.rb
2
+ # Month#day
3
+
4
+ require 'Month/self.day'
5
+
6
+ class Month
7
+
8
+ def day(date)
9
+ Month.day(date, month, year)
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ # Month/day_long.rb
2
+ # Month#day_long
3
+
4
+ require 'Month/self.day_long'
5
+
6
+ class Month
7
+
8
+ def day_long(date)
9
+ Month.day_long(date, month, year)
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ # Month/day_short.rb
2
+ # Month#day_short
3
+
4
+ require 'Month/self.day_short'
5
+
6
+ class Month
7
+
8
+ def day_short(date)
9
+ Month.day_short(date, month, year)
10
+ end
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ # Month/day_shortest.rb
2
+ # Month#day_shortest
3
+
4
+ require 'Month/self.day_shortest'
5
+
6
+ class Month
7
+
8
+ def day_shortest(date)
9
+ Month.day_shortest(date, month, year)
10
+ end
11
+
12
+ end
data/lib/Month/days.rb ADDED
@@ -0,0 +1,13 @@
1
+ # Month/days.rb
2
+ # Month#days
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.days'
6
+
7
+ class Month
8
+
9
+ def days
10
+ Month.days(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,10 @@
1
+ # Month/days_in_month.rb
2
+ # Month#days_in_month
3
+
4
+ require 'Month/days'
5
+
6
+ class Month
7
+
8
+ alias_method :days_in_month, :days
9
+
10
+ end
@@ -0,0 +1,10 @@
1
+ # Month/days_in_month.rb
2
+ # Month#days_in_month
3
+
4
+ require 'Month/days'
5
+
6
+ class Month
7
+
8
+ alias_method :days_in_the_month, :days
9
+
10
+ end
@@ -0,0 +1,13 @@
1
+ # Month/each_day.rb
2
+ # Month#each_day
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/days'
6
+
7
+ class Month
8
+
9
+ def each_day
10
+ (1..days).each{|day| yield day}
11
+ end
12
+
13
+ end
data/lib/Month/end.rb ADDED
@@ -0,0 +1,13 @@
1
+ # Month/end.rb
2
+ # Month#end
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.end'
6
+
7
+ class Month
8
+
9
+ def end
10
+ Month.end(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/end_date.rb
2
+ # Month#end_date
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.end_date'
6
+
7
+ class Month
8
+
9
+ def end_date
10
+ Month.end_date(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/end_of_month.rb
2
+ # Month#end_of_month
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.end_of_month'
6
+
7
+ class Month
8
+
9
+ def end_of_month
10
+ Month.end_of_month(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/end_of_the_month.rb
2
+ # Month#end_of_the_month
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.end_of_the_month'
6
+
7
+ class Month
8
+
9
+ def end_of_the_month
10
+ Month.end_of_the_month(year, month)
11
+ end
12
+
13
+ end
data/lib/Month/eqlQ.rb ADDED
@@ -0,0 +1,11 @@
1
+ # Month/eqlQ.rb
2
+ # Month#eql?
3
+
4
+ class Month
5
+
6
+ def eql?(other_month)
7
+ self.year == other_month.year && self.month == other_month.month
8
+ end
9
+ alias_method :==, :eql?
10
+
11
+ end
@@ -0,0 +1,13 @@
1
+ # Month/finish.rb
2
+ # Month#finish
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.finish'
6
+
7
+ class Month
8
+
9
+ def finish
10
+ Month.finish(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/finish_date.rb
2
+ # Month#finish_date
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.finish_date'
6
+
7
+ class Month
8
+
9
+ def finish_date
10
+ Month.finish_date(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/finish_of_month.rb
2
+ # Month#finish_of_month
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.finish_of_month'
6
+
7
+ class Month
8
+
9
+ def finish_of_month
10
+ Month.finish_of_month(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/finish_of_the_month.rb
2
+ # Month#finish_of_the_month
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.finish_of_the_month'
6
+
7
+ class Month
8
+
9
+ def finish_of_the_month
10
+ Month.finish_of_the_month(year, month)
11
+ end
12
+
13
+ end
data/lib/Month/hash.rb ADDED
@@ -0,0 +1,12 @@
1
+ # Month/hash.rb
2
+ # Month#hash
3
+
4
+ require 'Month/initialize'
5
+
6
+ class Month
7
+
8
+ def hash
9
+ "#{year}#{month}".to_i
10
+ end
11
+
12
+ end
@@ -0,0 +1,27 @@
1
+ # Month/initialize.rb
2
+ # Month#initialize
3
+
4
+ # Notes:
5
+ # 1. With a view to compatibility with Francis Hwang's version of a Month class, and as a nod to Ruby's Date class, I have made it possible to supply the year optionally, but first, rather than second if there are two arguments.
6
+ # 2. It might actually be nice if the Date class worked the same way.
7
+ # 3. Generally I find it the Ruby way to assume that which can be assumed, and to only require explicitness when necessary. In this instance that means that if I instantiate an object with a month only, then I should be able to assume the year.
8
+
9
+ require 'date'
10
+
11
+ class Month
12
+
13
+ attr_reader :month, :year
14
+
15
+ def initialize(*args)
16
+ @year, @month = (
17
+ case args.size
18
+ when 0; [Date.today.year, Date.today.month]
19
+ when 1; [Date.today.year, args[0]]
20
+ when 2; [args[0], args[1]]
21
+ else; raise ArgumentError, "too many arguments (#{args.size} for 0, 1, or 2)"
22
+ end
23
+ )
24
+ fail unless (1..12).include?(@month)
25
+ end
26
+
27
+ end
data/lib/Month/last.rb ADDED
@@ -0,0 +1,13 @@
1
+ # Month/last.rb
2
+ # Month#last
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.last'
6
+
7
+ class Month
8
+
9
+ def last
10
+ Month.last(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/last_month.rb
2
+ # Month#last_month
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.last_month'
6
+
7
+ class Month
8
+
9
+ def last_month
10
+ Month.last_month(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/last_year.rb
2
+ # Month#last_year
3
+
4
+ require 'Month/Constants'
5
+ require 'Month/initialize'
6
+
7
+ class Month
8
+
9
+ def last_year
10
+ Month.new(self.year - 1, self.month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,21 @@
1
+ # Month/method_missing.rb
2
+ # Month#method_missing
3
+
4
+ require 'Month/self.dates'
5
+
6
+ class Month
7
+
8
+ def method_missing(method_name, *args, &block)
9
+ case method_name.to_s
10
+ when /^((m|M)o)|((m|M)on)(day|days)*$/; Month.dates(year, month, :day => 'Monday')
11
+ when /^((t|T)u)|((t|T)ue)(sday|sdays)*$/; Month.dates(year, month, :day => 'Tuesday')
12
+ when /^((w|W)e)|((w|W)ed)(nesday|nesdays)*$/; Month.dates(year, month, :day => 'Wednesday')
13
+ when /^((t|T)h)|((t|T)hu)(rsday|rsdays)*$/; Month.dates(year, month, :day => 'Thursday')
14
+ when /^((f|F)r)|((f|F)ri)(day|days)*$/; Month.dates(year, month, :day => 'Friday')
15
+ when /^((s|S)a)|((s|S)at)(urday|urdays)*$/; Month.dates(year, month, :day => 'Saturday')
16
+ when /^((s|S)u)|((s|S)un)(day|days)*$/; Month.dates(year, month, :day => 'Sunday')
17
+ else; super(method_name, *args, &block)
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,20 @@
1
+ # Month/minus.rb
2
+ # Month#minus
3
+
4
+ require 'Month/initialize'
5
+
6
+ class Month
7
+
8
+ def minus(subtracted_months)
9
+ subtracted_years, remaining_months = subtracted_months.divmod(12)
10
+ preliminary_year = self.year - subtracted_years
11
+ if self.month > remaining_months
12
+ year, month = preliminary_year, self.month - remaining_months
13
+ else
14
+ year, month = preliminary_year - 1, 12 - (remaining_months - self.month)
15
+ end
16
+ Month.new(year, month)
17
+ end
18
+ alias_method :-, :minus
19
+
20
+ end
data/lib/Month/next.rb ADDED
@@ -0,0 +1,13 @@
1
+ # Month/next.rb
2
+ # Month#next
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.next'
6
+
7
+ class Month
8
+
9
+ def next
10
+ Month.next(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/next_month.rb
2
+ # Month#next_month
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.next_month'
6
+
7
+ class Month
8
+
9
+ def next_month
10
+ Month.next_month(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/next_year.rb
2
+ # Month#next_year
3
+
4
+ require 'Month/Constants'
5
+ require 'Month/initialize'
6
+
7
+ class Month
8
+
9
+ def next_year
10
+ Month.new(self.year + 1, self.month)
11
+ end
12
+
13
+ end
data/lib/Month/plus.rb ADDED
@@ -0,0 +1,16 @@
1
+ # Month/plus.rb
2
+ # Month#plus
3
+
4
+ require 'Month/initialize'
5
+
6
+ class Month
7
+
8
+ def plus(added_months)
9
+ added_years, remaining_months = added_months.divmod(12)
10
+ overflow_year, month = (self.month + remaining_months).divmod(12)
11
+ year = self.year + added_years + overflow_year
12
+ Month.new(year, month)
13
+ end
14
+ alias_method :+, :plus
15
+
16
+ end
data/lib/Month/prev.rb ADDED
@@ -0,0 +1,13 @@
1
+ # Month/prev.rb
2
+ # Month#prev
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.prev'
6
+
7
+ class Month
8
+
9
+ def prev
10
+ Month.prev(year, month)
11
+ end
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ # Month/prev_month.rb
2
+ # Month#prev_month
3
+
4
+ require 'Month/initialize'
5
+ require 'Month/self.prev_month'
6
+
7
+ class Month
8
+
9
+ def prev_month
10
+ Month.prev_month(year, month)
11
+ end
12
+
13
+ end