Merge pull request #1702 from ndbroadbent/fix_code

Tidy up some code in category_generator.rb
This commit is contained in:
Parker Moore 2014-12-27 15:03:04 -05:00
commit c811040d45

View File

@ -153,16 +153,7 @@ ERR
# Returns string # Returns string
# #
def category_links(categories) def category_links(categories)
categories = categories.sort!.map { |c| category_link c } categories.sort.map { |c| category_link c }.join(', ')
case categories.length
when 0
""
when 1
categories[0].to_s
else
"#{categories[0...-1].join(', ')}, #{categories[-1]}"
end
end end
# Outputs a single category as an <a> link. # Outputs a single category as an <a> link.
@ -183,8 +174,8 @@ ERR
# Returns string # Returns string
def date_to_html_string(date) def date_to_html_string(date)
result = '<span class="month">' + date.strftime('%b').upcase + '</span> ' result = '<span class="month">' + date.strftime('%b').upcase + '</span> '
result += date.strftime('<span class="day">%d</span> ') result << date.strftime('<span class="day">%d</span> ')
result += date.strftime('<span class="year">%Y</span> ') result << date.strftime('<span class="year">%Y</span> ')
result result
end end