This bit here can be written as: 
opening_name = time.opening_type.try(:name)
opening_time = "#{opening_name}#{":" if opening_name}#{time.name}"