Skip to content

Instantly share code, notes, and snippets.

@ryantss
Created April 19, 2010 05:08
Show Gist options
  • Save ryantss/370766 to your computer and use it in GitHub Desktop.
Save ryantss/370766 to your computer and use it in GitHub Desktop.
class Image
attr_accessor :property_id, :property_name, :url, :img_code, :img_name, :category, :caption, :description,
:width, :height, :original_size
def initialize(options = {})
options.each {|k,v| self.send("#{k}=", v) }
end
def self.from_csv(line, opts= {})
delim = opts[:delim] || '|'
image = Image.new
image.url, image.caption, image.description, image.category,
image.width, image.height = line.split(delim)
image
end
def to_csv(opts = {})
delim = opts[:delim] || '|'
[url, caption, description, category, property_id, width, height ].join(delim)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment