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|
74 fast = row[6].split(';')
77 bookclass = BookClass.new(grouping, title)
80 bookclass.author = author
81 bookclass.filename = filename
84 bookclass.add_fast(id)
87 key = construct_key(grouping, title)
88 @entries[key] = bookclass
90 #puts 'LOADED[' + key.inspect + ']: ' + bookclass.inspect
97 CSV.open(file_name, 'w:UTF-8') do |csv|
98 csv << ['Dewey', 'LCC', 'Grouping', 'Author', 'Filename', 'Title', 'FAST']
100 @entries.keys.sort.each do |key|
103 #puts 'SAVING[' + key.inspect + ']: ' + info.inspect
107 grouping = info.grouping
109 filename = info.filename
111 fast = info.fast.join(';')
113 csv << [ ddc, lcc, grouping, author, filename, title, fast ]
119 save(@@class_csv_file)