Class: Bmg::Reader::Csv
Constant Summary
collapse
- DEFAULT_OPTIONS =
{
:headers => true,
:return_headers => false
}
Constants included
from Algebra
Algebra::METHODS
Instance Attribute Summary
Attributes included from Bmg::Reader
#type
Instance Method Summary
collapse
#debug, #delete, empty, #empty?, #insert, new, #one, #one_or_nil, #to_json, #update, #visit, #ys_by_x
Methods included from Algebra
#allbut, #autosummarize, #autowrap, #constants, #extend, #image, #project, #rename, #restrict, #spied, #union, #unspied
Constructor Details
#initialize(type, path, options = {}) ⇒ Csv
11
12
13
14
15
16
17
|
# File 'lib/bmg/reader/csv.rb', line 11
def initialize(type, path, options = {})
@type = type
@path = path
@options = DEFAULT_OPTIONS.merge(options)
@options[:col_sep] ||= infer_col_sep
@options[:quote_char] ||= infer_quote_char
end
|
Instance Method Details
#each ⇒ Object
19
20
21
22
23
24
|
# File 'lib/bmg/reader/csv.rb', line 19
def each
require 'csv'
::CSV.foreach(@path, @options) do |row|
yield tuple(row)
end
end
|
#to_ast ⇒ Object
26
27
28
|
# File 'lib/bmg/reader/csv.rb', line 26
def to_ast
[ :csv, @path, @options ]
end
|
#to_s ⇒ Object
Also known as:
inspect
30
31
32
|
# File 'lib/bmg/reader/csv.rb', line 30
def to_s
"(csv #{path})"
end
|