Rails if else statement

Here i am going to give some example of conditional statements in Rails.
Normal IF ELSE
<% if user %>
<%= user.name %>
<% else %>
Anonymous
<% end %>

Normal code for ELSIF
if var == 10
print “Variable is 10″
elsif var == “20″
print “Variable is 20″
else
print “Variable is something else”
end

Technic:
How to Put this in one line:
<%= user.name if user %> This is the simplest way.

How to use IF and ELSE statement in one line:
<%= user ? user.name : “Anonymous” %>