diff --git a/rdoc/classes/Date.html b/rdoc/classes/Date.html new file mode 100644 index 0000000..e2c2fb5 --- /dev/null +++ b/rdoc/classes/Date.html @@ -0,0 +1,124 @@ + + + + +
+Class | +Date | +
In: | +
+
+ lib/smart_month/extensions/date.rb
+
+ + |
+
Parent: | ++ Object + | +
+inject the extension mixin to the base class +
+ +- # File lib/month.rb, line 25 -25: def initialize(month = Time.now.mon, year = Time.now.year) -26: @date = Date.new(year,( month.is_a?(Integer) ? month : Month::NAMES.index(month.to_s.capitalize) ) ,1) -27: end + # File lib/month.rb, line 23 +23: def initialize(month = Time.now.mon, year = Time.now.year) +24: @date = Date.new(year,( month.is_a?(Integer) ? month : Month::NAMES.index(month.to_s.capitalize) ) ,1) +25: end
+This module extends the core Date class +functionality for use throughout smart_month. +
+ +# File lib/smart_month/calculations.rb, line 34 34: def every(*days) @@ -162,23 +162,23 @@Public Instance methods
-this returns the same data as every +this returns the same data as every but removes the hash organization of the data.
-# File lib/smart_month/calculations.rb, line 58 58: def every!(*days) @@ -190,24 +190,24 @@Public Instance methods
-returns the first date of the day +returns the first date of the day requested. if no day is defined, it returns the very first day of the month. +href="Calculations.html#M000030">first day of the month.
-# File lib/smart_month/calculations.rb, line 6 6: def first(day = nil) @@ -218,23 +218,23 @@Public Instance methods
-returns the fourth (or potentially -last), date of the day requested. +returns the fourth (or potentially +last), date of the day requested.
-# File lib/smart_month/calculations.rb, line 21 21: def fourth(day) @@ -245,24 +245,24 @@Public Instance methods
-returns last date of the day +returns last date of the day requested. if no day is defined, it returns the very last day of the month. +href="Calculations.html#M000034">last day of the month.
-# File lib/smart_month/calculations.rb, line 27 27: def last(day = nil) @@ -273,8 +273,8 @@Public Instance methods
-returns the second date of the day +returns the second date of the day requested.
-# File lib/smart_month/calculations.rb, line 11 11: def second(day) @@ -314,11 +314,11 @@Public Instance methods
# File lib/smart_month/calculations.rb, line 64 64: def size @@ -340,23 +340,23 @@Public Instance methods
-returns the third date of the day +returns the third date of the day requested.
-# File lib/smart_month/calculations.rb, line 16 16: def third(day) diff --git a/rdoc/classes/SmartMonth/Collection.html b/rdoc/classes/SmartMonth/Collection.html index a638daa..f8e8333 100644 --- a/rdoc/classes/SmartMonth/Collection.html +++ b/rdoc/classes/SmartMonth/Collection.html @@ -86,13 +86,13 @@Methods
-allows us to iterate internally on the days of a given month. It also uses -the helpful Day class that provides some -fun methods. (see SmartMonth::Collection::Day) +allows us to iterate internally on the days of a given month.
-- # File lib/smart_month/collection.rb, line 60 -60: def each(first = 1, last = self.last.day, &block) -61: (1..self.last.day).each do |e| -62: block.call(Day.new(Date.new(@date.year,@date.month,e))) -63: end -64: return self -65: end + # File lib/smart_month/collection.rb, line 44 +44: def each(first = 1, last = self.last.day, &block) +45: (1..self.last.day).each do |e| +46: block.call(Date.new(@date.year,@date.month,e)) +47: end +48: return self +49: end
- # File lib/smart_month/collection.rb, line 21 -21: def next -22: if @date.month + 1 > 12 -23: Month.new(1,@date.year+1) -24: else -25: Month.new(@date.month+1,@date.year) -26: end -27: end + # File lib/smart_month/collection.rb, line 6 + 6: def next + 7: if @date.month + 1 > 12 + 8: Month.new(1,@date.year+1) + 9: else +10: Month.new(@date.month+1,@date.year) +11: end +12: end
- # File lib/smart_month/collection.rb, line 30 -30: def next! -31: if @date.month + 1 > 12 -32: @date = Date.new(@date.year+1,@date.month,1) -33: else -34: @date = Date.new(@date.year,@date.month+1,1) -35: end -36: end + # File lib/smart_month/collection.rb, line 15 +15: def next! +16: if @date.month + 1 > 12 +17: @date = Date.new(@date.year+1,@date.month,1) +18: else +19: @date = Date.new(@date.year,@date.month+1,1) +20: end +21: end
- # File lib/smart_month/collection.rb, line 39 -39: def previous -40: if @date.month - 1 == 0 -41: Month.new(12,@date.year-1) -42: else -43: Month.new(@date.month-1,@date.year) -44: end -45: end + # File lib/smart_month/collection.rb, line 24 +24: def previous +25: if @date.month - 1 == 0 +26: Month.new(12,@date.year-1) +27: else +28: Month.new(@date.month-1,@date.year) +29: end +30: end
- # File lib/smart_month/collection.rb, line 49 -49: def previous! -50: if @date.month - 1 == 0 -51: @date = Date.new(@date.year-1,12,1) -52: else -53: @date = Date.new(@date.year,@date.month-1,1) -54: end -55: end + # File lib/smart_month/collection.rb, line 34 +34: def previous! +35: if @date.month - 1 == 0 +36: @date = Date.new(@date.year-1,12,1) +37: else +38: @date = Date.new(@date.year,@date.month-1,1) +39: end +40: end
Module | +SmartMonth::Extensions | +
In: | +
+
+ lib/smart_month/extensions/date.rb
+
+ + |
+
Module | +SmartMonth::Extensions::Date | +
In: | +
+
+ lib/smart_month/extensions/date.rb
+
+ + |
+
+this is to make date objects more console-friendly +
+ ++ # File lib/smart_month/extensions/date.rb, line 8 + 8: def inspect + 9: strftime("%a, %d %b %Y") +10: end ++
+allows a date to return the day of the week it currently is as a string +
+ ++ # File lib/smart_month/extensions/date.rb, line 18 +18: def to_day +19: Month::DAYS[self.wday] +20: end ++
+allows a date to retrun the current day its set to as an integer +
+ ++ # File lib/smart_month/extensions/date.rb, line 13 +13: def to_i +14: self.day.to_i +15: end ++
- # File lib/smart_month/math.rb, line 30 -30: def %(int) -31: self.to_i % int -32: end + # File lib/smart_month/math.rb, line 31 +31: def %(int) +32: self.to_i % int +33: end
- # File lib/smart_month/math.rb, line 15 -15: def *(int) -16: self.to_i * int -17: end + # File lib/smart_month/math.rb, line 16 +16: def *(int) +17: self.to_i * int +18: end
- # File lib/smart_month/math.rb, line 25 -25: def **(int) -26: self.to_i ** int -27: end + # File lib/smart_month/math.rb, line 26 +26: def **(int) +27: self.to_i ** int +28: end
- # File lib/smart_month/math.rb, line 5 -5: def +(int) -6: self.to_i + int -7: end + # File lib/smart_month/math.rb, line 6 +6: def +(int) +7: self.to_i + int +8: end
- # File lib/smart_month/math.rb, line 10 -10: def -(int) -11: self.to_i - int -12: end + # File lib/smart_month/math.rb, line 11 +11: def -(int) +12: self.to_i - int +13: end
- # File lib/smart_month/math.rb, line 20 -20: def /(int) -21: self.to_i / int -22: end + # File lib/smart_month/math.rb, line 21 +21: def /(int) +22: self.to_i / int +23: end
- # File lib/smart_month/math.rb, line 35 -35: def ==(month) -36: self.inspect! == month.inspect! -37: end + # File lib/smart_month/math.rb, line 36 +36: def ==(month) +37: self.inspect! == month.inspect! +38: end
- # File lib/smart_month/rulesets.rb, line 5 -5: def self.load(path) -6: @@ruleset_yml = YAML::load(File.open(path)) -7: end --
- # File lib/smart_month/rulesets.rb, line 16 -16: def self.parse_date(rule) -17: month,day,year = rule.split -18: day.gsub!(',','') -19: day.gsub!(/st|rd|th|nd/,'') -20: {:year => year, :month => month, :day => day} -21: end --
- # File lib/smart_month/rulesets.rb, line 9 - 9: def create_condition_with_date -10: end + # File lib/smart_month/rulesets.rb, line 6 +6: def self.load(path) +7: @@ruleset_yml = YAML::load(File.open(path)) +8: end
- # File lib/smart_month/rulesets.rb, line 12 -12: def create_condition_with_frequency -13: "([Month.new(#{month}).#{freq}!(#{days})].flatten.include? Date.new(self.year,self.month,self.day)) ? true : false" -14: end + # File lib/smart_month/rulesets.rb, line 10 +10: def self.parse_string_as_date(rule) +11: month,day,year = rule.split +12: day.gsub!(',','') +13: day.gsub!(/st|rd|th|nd/,'') +14: {:year => year, :month => month, :day => day} +15: end
-returns the month and the year as a string. +returns the month and the year as a string.
-- # File lib/smart_month/util.rb, line 15 -15: def inspect! -16: "#{self.to_s} #{@date.year}" -17: end + # File lib/smart_month/util.rb, line 10 +10: def inspect! +11: "#{self.to_s} #{self.year}" +12: end
-returns the month as a fixnum. +returns the month as a fixnum.
-- # File lib/smart_month/util.rb, line 25 -25: def to_i -26: Month::NAMES.index(self.to_s) -27: end + # File lib/smart_month/util.rb, line 20 +20: def to_i +21: Month::NAMES.index(self.to_s) +22: end
-returns the month as a string. +returns the month as a string.
-- # File lib/smart_month/util.rb, line 20 -20: def to_s -21: Month::NAMES[@date.month] -22: end + # File lib/smart_month/util.rb, line 15 +15: def to_s +16: Month::NAMES[self.month] +17: end
-returns the year of the current month. +returns the year of the current month.
-- # File lib/smart_month/util.rb, line 10 -10: def year -11: @date.year -12: end + # File lib/smart_month/util.rb, line 27 +27: def year +28: @date.year +29: end
SmartMonth is a -"bodysnatcher" plugin that takes boring Date month fixnums and -replaces them with a rich toolkit of functionality. You can use Date month fixnums and replaces them with a +rich toolkit of functionality. You can use SmartMonth to:
Path: | +lib/smart_month/extensions/date.rb + | +
Last Update: | +Wed Feb 18 12:57:19 -0800 2009 | +
+This module extends the core Date class functionality for use +throughout smart_month. +
+ +