summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorspag <spag@golwen.net>2012-12-31 08:50:27 +0100
committerspag <spag@golwen.net>2012-12-31 08:50:27 +0100
commitaed84444142604a62e37e57acfaaf957219e2c8d (patch)
treee00b1f5844590393171e0bc839ab516d39f5144d /app/helpers
parentc24bd3a8212e85894b2f7c26e190fe5e89fbaaf2 (diff)
parent12c8f4c82770ded6ea6b519e4451ed6757419ddf (diff)
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index de6be79..de4d677 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,2 +1,22 @@
module ApplicationHelper
+
+ # nicely_joined_with_commata(['1', '2', '3', '4'])
+ # = '1, 2, 3 und 4'
+ #
+ def nicely_joined_with_commata(array_of_things)
+ if array_of_things.count == 1
+ array_of_things.first.to_s
+ else
+ if array_of_things.count > 1
+ output = array_of_things[0, array_of_things.count - 1].map{|item| item.to_s}.join(', ')
+ if I18n.locale == :de
+ output += ' und '
+ else
+ output += ' and '
+ end
+ output += array_of_things.last.to_s
+ end
+ end
+ end
+
end