Formatting a possibly nil value as hours and minutes
In one line

def length
  (len = read_attribute(:length)) &amp;&amp; "#{(len/60/60).floor}h #{len.modulo(60*60)/60}m"
end


If len == nil return nil, if not - second operand