Class CSV::IOReader
In: lib/csv.rb
Parent: Reader

Methods

Public Class methods

[Source]

     # File lib/csv.rb, line 616
616:     def initialize(io, fs = ',', rs = nil)
617:       @io = io
618:       @fs = fs
619:       @rs = rs
620:       @dev = CSV::IOBuf.new(@io)
621:       @idx = 0
622:       if @dev[0] == 0xef and @dev[1] == 0xbb and @dev[2] == 0xbf
623:         @idx += 3
624:       end
625:       @close_on_terminate = false
626:     end

Public Instance methods

Tell this reader to close the IO when terminated (Triggered by invoking CSV::IOReader#close).

[Source]

     # File lib/csv.rb, line 630
630:     def close_on_terminate
631:       @close_on_terminate = true
632:     end

Private Instance methods

[Source]

     # File lib/csv.rb, line 636
636:     def get_row(row)
637:       parsed_cells, next_idx = CSV.parse_row(@dev, @idx, row, @fs, @rs)
638:       if parsed_cells == 0 and next_idx == 0 and !@dev.is_eos?
639:         raise IllegalFormatError.new
640:       end
641:       dropped = @dev.drop(next_idx)
642:       @idx = next_idx - dropped
643:       parsed_cells
644:     end

[Source]

     # File lib/csv.rb, line 646
646:     def terminate
647:       if @close_on_terminate
648:         @io.close
649:       end
650: 
651:       if @dev
652:         @dev.close
653:       end
654:     end

[Validate]