Class: BerkeleyLibrary::Holdings::XLSXReader

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/berkeley_library/holdings/xlsx_reader.rb

Constant Summary

Constants included from Constants

Constants::OCLC_COL_HEADER

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xlsx_path) ⇒ XLSXReader

Returns a new instance of XLSXReader.



13
14
15
16
# File 'lib/berkeley_library/holdings/xlsx_reader.rb', line 13

def initialize(xlsx_path)
  @ss = Util::XLSX::Spreadsheet.new(xlsx_path)
  @oclc_col_index = ss.find_column_index_by_header!(OCLC_COL_HEADER)
end

Instance Attribute Details

#oclc_col_indexObject (readonly)

Returns the value of attribute oclc_col_index.



11
12
13
# File 'lib/berkeley_library/holdings/xlsx_reader.rb', line 11

def oclc_col_index
  @oclc_col_index
end

#ssObject (readonly)

Returns the value of attribute ss.



11
12
13
# File 'lib/berkeley_library/holdings/xlsx_reader.rb', line 11

def ss
  @ss
end

Instance Method Details

#each_oclc_numberObject



18
19
20
21
22
23
24
25
26
# File 'lib/berkeley_library/holdings/xlsx_reader.rb', line 18

def each_oclc_number
  return to_enum(:each_oclc_number) unless block_given?

  ss.each_value(oclc_col_index, include_header: false) do |v|
    next if (v_str = v.to_s).strip == ''

    yield v_str
  end
end