Use if blocks instead of two ternary operators

Using a simple ternary operator is usually fine; however, code combining
two ternary operator is a bit hard to follow.
This commit is contained in:
Javi Martín
2019-01-10 15:09:58 +01:00
parent eb6bba52e3
commit 68fb295db5

View File

@@ -16,8 +16,15 @@ module BudgetInvestmentsHelper
end
def set_sorting_icon(direction, sort_by)
icon = direction == "desc" ? "icon-arrow-top" : "icon-arrow-down"
icon = sort_by.to_s == params[:sort_by] ? icon : ""
if sort_by.to_s == params[:sort_by]
if direction == "desc"
"icon-arrow-top"
else
"icon-arrow-down"
end
else
""
end
end
def set_direction(current_direction)