Module: FightCSV::Record::ClassMethods
- Defined in:
- lib/fight_csv/record.rb
Instance Method Summary collapse
- #import(io) ⇒ Object
- #records(io) ⇒ Object
- #schema(filename = nil, &block) ⇒ Object
- #schema=(schema) ⇒ Object
Instance Method Details
#import(io) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fight_csv/record.rb', line 15 def import(io) Enumerator.new do |yielder| record = self.new data_source = DataSource.new(io: io) data_source.each do |row, additions| record.header = additions[:header] record.row = row yielder << record end end end |
#records(io) ⇒ Object
10 11 12 13 |
# File 'lib/fight_csv/record.rb', line 10 def records(io) data_source = DataSource.new(io: io) data_source.map { |row,additions|self.new(row, additions) } end |
#schema(filename = nil, &block) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/fight_csv/record.rb', line 27 def schema(filename = nil, &block) if filename || block @schema = Schema.new(filename, &block) else @schema end end |
#schema=(schema) ⇒ Object
6 7 8 |
# File 'lib/fight_csv/record.rb', line 6 def schema=(schema) @schema = schema end |