Skip to content

Instantly share code, notes, and snippets.

@knzconnor
Forked from ymendel/gist:496384
Created July 28, 2010 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save knzconnor/496394 to your computer and use it in GitHub Desktop.
Save knzconnor/496394 to your computer and use it in GitHub Desktop.
def address(separator, seperator2=' ')
fields_array = [:billing_address1, :billing_address2, :billing_city, :billing_state, :billing_zip, :billing_phone]
(0..10).inject("") { |string, i|
if i.odd?
field = :seperator
field = (field.to_s + '2').intern if i == 7
else
field = fields_array[i/2]
end
temp = send(field) rescue nil
unless !temp.blank?
temp = eval "#{field.to_s}" rescue nil
end
string += temp.blank? ? string : string + temp
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment