Permalink
Browse files

seperator patch and better naming conventions

  • Loading branch information...
1 parent 1d7ddc9 commit 8a99e9ec298b5a882de6f3b0b55e670840ad8119 Josh Goebel committed May 18, 2008
Showing with 9 additions and 6 deletions.
  1. +3 −3 README
  2. +3 −1 lib/year_after_year.rb
  3. +3 −2 spec/year_after_year_spec.rb
View
6 README
@@ -15,9 +15,9 @@ year that you started.
Example: With the assumption that the current year was 2008
- <%= year_range(2005) -%> # => 2005-2008
- <%= year_range(2005, '&mdash;') -%> # => 2005&mdash;2008
- <%= year_range(2008) -%> # => 2008 (just returns current year)
+ <%= current_year_range(2005) -%> # => 2005-2008
+ <%= current_year_range(2005, '&mdash;') -%> # => 2005&mdash;2008
+ <%= current_year_range(2008) -%> # => 2008 (just returns current year)
You can access the code here:
View
@@ -6,8 +6,10 @@ def current_year
Time.now.year
end
- def year_range( start_year = current_year, separator = '-' )
+ def current_year_range( start_year = current_year, separator = '-' )
[start_year, current_year].sort.uniq.join(separator)
end
+
+ alias :year_range :current_year_range
end
end
@@ -20,14 +20,15 @@
end
it 'should return a range of years when provided a start year' do
- year_range(2004).should == '2004-2006'
+ current_year_range(2004).should == '2004-2006'
end
it "should return a range of years with the specified separator" do
- year_range(2004, '&mdash;').should == '2004&mdash;2006'
+ current_year_range(2004, '&mdash;').should == '2004&mdash;2006'
end
it 'should return only the current year if the start year is the same' do
+ current_year_range(2006).should == '2006'
year_range(2006).should == '2006'
end
end

0 comments on commit 8a99e9e

Please sign in to comment.