Skip to content

Instantly share code, notes, and snippets.

@jbarnette
Forked from ymendel/gist:496384
Created July 29, 2010 21:23
Show Gist options
  • Save jbarnette/499278 to your computer and use it in GitHub Desktop.
Save jbarnette/499278 to your computer and use it in GitHub Desktop.
################################################################################
### M E T H O D N A M E :: address ############################################
### A R G U M E N T S :: separator[String] ##################################
### R E T U R N S :: String #############################################
### A U T H O R :: Alan Smithee #######################################
### D A T E :: 1989-10-31 #########################################
################################################################################
def address separator
# THIS IS OUR ADDRESS TEMPLATE
%q(
Billing Address 1
Billing Address 2
Billing City
Billing State Billing Zip
Billing Phone
).
# AND NOW WE GENERATE THE ADDRESS
gsub(/(Billing\s+\w+)(\s+(\d+))?/) {
$1.downcase.tr(" ", "_") + ($3 || "") }.strip.
gsub(/^\s+/) { "" }.gsub(/(\w+)/) { send $1 }.gsub(/\n$/, separator)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment