Class: Bmg::Reader::Csv
- Inherits:
-
Object
- Object
- Bmg::Reader::Csv
- Includes:
- Bmg::Reader
- Defined in:
- lib/bmg/reader/csv.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :headers => true, :return_headers => false, :smart => true }
Instance Attribute Summary
Attributes included from Bmg::Reader
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(type, path_or_io, options = {}) ⇒ Csv
constructor
A new instance of Csv.
- #to_ast ⇒ Object
- #to_s ⇒ Object (also: #inspect)
Methods included from Bmg::Relation
#_count, #bind, #count, #debug, #delete, empty, #empty?, #insert, new, #one, #one_or_nil, #to_csv, #to_json, #to_xlsx, #type, #update, #visit, #with_type, #with_type_attrlist, #with_typecheck, #without_typecheck, #y_by_x, #ys_by_x
Methods included from Algebra
#allbut, #autosummarize, #autowrap, #constants, #extend, #group, #image, #join, #left_join, #matching, #materialize, #minus, #not_matching, #page, #project, #rename, #restrict, #spied, #summarize, #transform, #ungroup, #union, #unspied, #unwrap
Methods included from Algebra::Shortcuts
#cross_product, #exclude, #image, #images, #join, #left_join, #matching, #not_matching, #prefix, #rxmatch, #suffix, #ungroup, #unwrap, #where
Constructor Details
#initialize(type, path_or_io, options = {}) ⇒ Csv
Returns a new instance of Csv.
12 13 14 15 16 17 18 |
# File 'lib/bmg/reader/csv.rb', line 12 def initialize(type, path_or_io, = {}) require 'csv' @path_or_io = path_or_io @options = () @type = handle_type(type) end |
Instance Method Details
#each ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/bmg/reader/csv.rb', line 20 def each return to_enum unless block_given? with_csv do |csv| csv.each do |row| yield tuple(row) end end end |
#to_ast ⇒ Object
30 31 32 |
# File 'lib/bmg/reader/csv.rb', line 30 def to_ast [ :csv, @path_or_io, @options ] end |
#to_s ⇒ Object Also known as: inspect
34 35 36 |
# File 'lib/bmg/reader/csv.rb', line 34 def to_s "(csv #{@path_or_io})" end |