6 @@class_csv_file = 'class.csv'
10 load!(@@class_csv_file)
14 key = construct_key(info.grouping, info.title)
18 def construct_key(author_grouping, title)
19 author_grouping.to_s + '|' + title.to_s
22 def get(author_grouping, title)
23 key = construct_key(author_grouping, title)
24 if @entries.has_key?(key)
31 def has_key?(author_grouping, title)
32 @entries.has_key?(construct_key(author_grouping, title))
35 def ensure_contains!(info)
36 if ! has_key?(info.grouping, info.title)
45 data.push('entries=' + @entries.inspect + '')
48 return '(ClassSet:' + data.join(',') + ')'
55 if ! File.exist?(file_name)
56 puts 'WARNING: file "' + file_name + '" not found.'
60 File.open(file_name, 'r:UTF-8') do |fd|
62 csv.to_a.each do |row|
73 fast = row[5].split(';')
76 bookclass = BookClass.new(grouping, title)
79 bookclass.author = author
82 bookclass.add_fast(id)
85 key = construct_key(grouping, title)
86 @entries[key] = bookclass
93 CSV.open(file_name, 'w:UTF-8') do |csv|
94 csv << ['Dewey', 'LCC', 'Grouping', 'Author', 'Title', 'FAST']
96 @entries.keys.sort.each do |key|
101 grouping = info.grouping
104 fast_list = info.fast
106 fast_list.each do |tuple|
107 fast_ids.push(tuple[0])
109 fast = fast_ids.join(';')
111 csv << [ ddc, lcc, grouping, author, title, fast ]
117 save(@@class_csv_file)