Permalink
Browse files

Renamed rewind_to_monday -> beginning_of_workweek

  • Loading branch information...
1 parent 52eaf9d commit 1dfafaa3fb17913b0824d849d04915f513a83478 @dbrady committed Mar 14, 2012
Showing with 6 additions and 6 deletions.
  1. +2 −2 lib/planner.rb
  2. +4 −4 spec/lib/planner_spec.rb
View
@@ -44,7 +44,7 @@ class Planner
GRAPH_CELL_WIDTH=9
def self.draw(start_date, filename)
- start_date = self.rewind_to_monday start_date
+ start_date = self.beginning_of_workweek start_date
pdf = generate_planner_pdf start_date
save_pdf pdf, filename
end
@@ -67,7 +67,7 @@ def self.open_file(filename, mode, &block)
end
# Returns first Monday on or before start_date
- def self.rewind_to_monday(start_date)
+ def self.beginning_of_workweek(start_date)
delta = start_date.wday - 1
delta += 7 if delta < 0 # Sundays will advance the date by default
start_date -= delta
View
@@ -11,17 +11,17 @@ def md5(string)
end
describe Planner do
- describe ".rewind_to_monday" do
+ describe ".beginning_of_workweek" do
it "rewinds date to previous Monday" do
- Planner.rewind_to_monday(Date.parse('2012-03-15')).should == Date.parse('2012-03-12')
+ Planner.beginning_of_workweek(Date.parse('2012-03-15')).should == Date.parse('2012-03-12')
end
it "does not rewind if given date is a Monday" do
- Planner.rewind_to_monday(Date.parse('2012-03-12')).should == Date.parse('2012-03-12')
+ Planner.beginning_of_workweek(Date.parse('2012-03-12')).should == Date.parse('2012-03-12')
end
it "rewinds if given date is a Sunday" do
- Planner.rewind_to_monday(Date.parse('2012-03-11')).should == Date.parse('2012-03-05')
+ Planner.beginning_of_workweek(Date.parse('2012-03-11')).should == Date.parse('2012-03-05')
end
end

0 comments on commit 1dfafaa

Please sign in to comment.