Fix verbose code with a one liner
authorNathan Broadbent <nathan.f77@gmail.com>
Sat, 27 Dec 2014 15:11:09 +0000 (21:11 +0600)
committerNathan Broadbent <nathan.f77@gmail.com>
Sat, 27 Dec 2014 15:11:09 +0000 (21:11 +0600)
plugins/category_generator.rb

index c55d62f..9beef9b 100644 (file)
@@ -153,16 +153,7 @@ ERR
     # Returns string
     #
     def category_links(categories)
-      categories = categories.sort!.map { |c| category_link c }
-
-      case categories.length
-      when 0
-        ""
-      when 1
-        categories[0].to_s
-      else
-        "#{categories[0...-1].join(', ')}, #{categories[-1]}"
-      end
+      categories.sort.map { |c| category_link c }.join(', ')
     end
 
     # Outputs a single category as an <a> link.