diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-08-26 16:37:11 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-08-26 16:37:11 +0000 |
commit | 91380eeaab3028aac9a33559fe3932a86b066b6e (patch) | |
tree | 5f51614aa0a89087f9794d6b14917fd0bb620970 /app/helpers/calendars_helper.rb | |
parent | 3eea03d70efd4e894a5020e8bae62a6af6e59803 (diff) | |
download | redmine-91380eeaab3028aac9a33559fe3932a86b066b6e.tar.gz redmine-91380eeaab3028aac9a33559fe3932a86b066b6e.zip |
Refactor: extract ternary operators to temps.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4043 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/calendars_helper.rb')
-rw-r--r-- | app/helpers/calendars_helper.rb | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/app/helpers/calendars_helper.rb b/app/helpers/calendars_helper.rb index d3544f267..52cc42512 100644 --- a/app/helpers/calendars_helper.rb +++ b/app/helpers/calendars_helper.rb @@ -1,14 +1,38 @@ module CalendarsHelper def link_to_previous_month(year, month) - link_to_remote ('« ' + (month==1 ? "#{month_name(12)} #{year-1}" : "#{month_name(month-1)}")), - {:update => "content", :url => { :year => (month==1 ? year-1 : year), :month =>(month==1 ? 12 : month-1) }}, - {:href => url_for(:action => 'show', :year => (month==1 ? year-1 : year), :month =>(month==1 ? 12 : month-1))} + target_year, target_month = if month == 1 + [year - 1, 12] + else + [year, month - 1] + end + + name = if target_month == 12 + "#{month_name(target_month)} #{target_year}" + else + "#{month_name(target_month)}" + end + + link_to_remote ('« ' + name), + {:update => "content", :url => { :year => target_year, :month => target_month }}, + {:href => url_for(:action => 'show', :year => target_year, :month => target_month)} end def link_to_next_month(year, month) - link_to_remote ((month==12 ? "#{month_name(1)} #{year+1}" : "#{month_name(month+1)}") + ' »'), - {:update => "content", :url => { :year => (month==12 ? year+1 : year), :month =>(month==12 ? 1 : month+1) }}, - {:href => url_for(:action => 'show', :year => (month==12 ? year+1 : year), :month =>(month==12 ? 1 : month+1))} + target_year, target_month = if month == 12 + [year + 1, 1] + else + [year, month + 1] + end + + name = if target_month == 1 + "#{month_name(target_month)} #{target_year}" + else + "#{month_name(target_month)}" + end + + link_to_remote (name + ' »'), + {:update => "content", :url => { :year => target_year, :month => target_month }}, + {:href => url_for(:action => 'show', :year => target_year, :month =>target_month)} end end |