I have this simple helper:
def printe_result(data)
a_var = ('<a href="http://'+data.a_value+'>A</a>' unless (data.a_value.nil? || data.a_value.empty?))
b_var = ('<a href="http://'+data.b_value+'>B</a>' unless (data.b_value.nil? || data.b_value.empty?))
c_var = ('<a href="http://'+data.c_value+'>C</a>' unless (data.c_value.nil? || data.c_value.empty?))
return ...
end
a_value, b_value, c_value I am taking from database. If the values are strings, I want to save them into the respective variable and then all variables return as one string with the values separated by comma, for example:
"<a href=http://a>A</a>, <a href=http://b>B</a>, <a href=http://c>C</a>"
How can I merge the variables only if they exist?