Class: BibliographicalImporter::CSV::Reader

Inherits:
Object
  • Object
show all
Includes:
AbstractReader, Enumerable
Defined in:
lib/bibliographical_importer/csv.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(csv_o, base) ⇒ Reader

Returns a new instance of Reader



114
115
116
117
118
# File 'lib/bibliographical_importer/csv.rb', line 114

def initialize(csv_o, base)
  @csv=csv_o
  @base=base
  parse_records
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base



103
104
105
# File 'lib/bibliographical_importer/csv.rb', line 103

def base
  @base
end

#csvObject (readonly)

Returns the value of attribute csv



101
102
103
# File 'lib/bibliographical_importer/csv.rb', line 101

def csv
  @csv
end

#recordsObject (readonly)

Returns the value of attribute records



102
103
104
# File 'lib/bibliographical_importer/csv.rb', line 102

def records
  @records
end

Class Method Details

.open(filename) ⇒ Object



120
121
122
# File 'lib/bibliographical_importer/csv.rb', line 120

def self.open(filename)
  raise "Not implemented"
end

.parse(string, base) ⇒ Object



124
125
126
127
128
# File 'lib/bibliographical_importer/csv.rb', line 124

def self.parse(string, base)
  require 'csv'
  b=::CSV.parse(string, :headers => true)
  Reader.new(b, base)
end

Instance Method Details

#[](x) ⇒ Object



106
107
108
# File 'lib/bibliographical_importer/csv.rb', line 106

def [](x)
  @records[x]
end

#each(&block) ⇒ Object



110
111
112
# File 'lib/bibliographical_importer/csv.rb', line 110

def each(&block)
  @records.each(&block)
end

#parse_recordsObject



130
131
132
133
134
135
136
137
# File 'lib/bibliographical_importer/csv.rb', line 130

def parse_records
  #$log.info(base)
  if base=="refworks"
    @records=@csv.map {|r| BibliographicalImporter::CSV::Record_Refworks.create(r)}
  else
    raise "TODO"
  end
end