Skip to content

thinkcreate/csvmapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

DESCRIPTION:

CSVMapper easily maps csv-data to a class.

EXAMPLES:

module Shop
  class Product
    include CSVMapper

    column :name, 'product_name'
    column :uid, 'product_uid', Integer
    column :description, 2
    column(:price_in_cents, 'product_price', Float){|float| (float * 100).round }

  end
end

csv =<<-CSV.gsub(/^ +/,'')
  product_uid,product_name,product_description,product_price
  1200,Ham,like you never tasted before,19.99
CSV

p1 = Shop::Product.parse(csv).first
p1.price_in_cents   # 1999

Enjoy!

REQUIREMENTS:

FasterCSV

LICENSE:

/*

* Copyright (c) 2009 Gert Goet
* ----------------------------------------------------------------------------
* "THE SHIRT-WARE LICENSE" (Revision 10):
* http://github.com/thinkcreate wrote this software.
* As long as you retain this notice you can do whatever you want with this stuff. 
* If you think this stuff is worth it, you can buy me a github-shirt in return.
* ----------------------------------------------------------------------------
*/

About

Easily map csv-data to a class

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages