Skip to content

Instantly share code, notes, and snippets.

@wilson
Forked from knzconnor/gist:496394
Created July 28, 2010 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save wilson/496546 to your computer and use it in GitHub Desktop.
Save wilson/496546 to your computer and use it in GitHub Desktop.
def address(separator, seperator2=' ')
fields_array = %w(address1 address2 city state zip phone).map {|t| [:billing,t].join('_').to_sym}
(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