Class: VFCSV::Instance

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/vfcsv.rb

Overview

Instance wrapper for stateful CSV operations

Instance Method Summary collapse

Constructor Details

#initialize(data = nil, **options) ⇒ Instance

Returns a new instance of Instance.



530
531
532
533
534
# File 'lib/vfcsv.rb', line 530

def initialize(data = nil, **options)
  @data = data
  @options = VFCSV::DEFAULT_OPTIONS.merge(options)
  @rows = nil
end

Instance Method Details

#each(&block) ⇒ Object



536
537
538
539
540
# File 'lib/vfcsv.rb', line 536

def each(&block)
  return to_enum(__method__) unless block_given?
  ensure_parsed
  @rows.each(&block)
end

#headersObject



547
548
549
550
# File 'lib/vfcsv.rb', line 547

def headers
  ensure_parsed
  @rows.respond_to?(:headers) ? @rows.headers : nil
end

#readObject



542
543
544
545
# File 'lib/vfcsv.rb', line 542

def read
  ensure_parsed
  @rows
end