1 2 3 4 5 6 7 8 9 10 |
# The following code will create a temporary file for say attaching a vcard file to email.The following code is dynamic to use ERB to create a template to create the file dynamically every time with the variable "telephone","location","email" which gets binded to the ERB file and is under scope { telephone = "347-27456" location = "New Delhi" email = "xyz@gmail.com" vcard = ERB( File('address.vcard.erb' ){|f| f } )( binding ) f = File("temp_file.vcf","wb") f vcard f } |
