Class: MasterRecord::CSV
- Inherits:
-
Object
- Object
- MasterRecord::CSV
- Includes:
- Enumerable
- Defined in:
- lib/master_record/csv.rb
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(datum) ⇒ CSV
constructor
A new instance of CSV.
Constructor Details
#initialize(datum) ⇒ CSV
Returns a new instance of CSV.
21 22 23 |
# File 'lib/master_record/csv.rb', line 21 def initialize(datum) @datum = ::CSV.parse(datum) end |
Class Method Details
.load_file(file, headers = false) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/master_record/csv.rb', line 12 def self.load_file(file,headers=false) contents = File.read(file) if headers new(contents.sub(/^[^\n]+\n/,'')) else new(contents) end end |
Instance Method Details
#each ⇒ Object
6 7 8 9 10 |
# File 'lib/master_record/csv.rb', line 6 def each @datum.each do|data| yield data end end |