7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/marc/dublincore.rb', line 7
def self.map(record)
dc_hash = Hash.new
dc_hash['title'] = get_field_value(record['245']['a'])
[100, 110, 111, 700, 710, 711, 720].each do |field|
dc_hash['creator'] ||= []
dc_hash['creator'] << get_field_value(record[field.to_s])
end
[600, 610, 611, 630, 650, 653].each do |field|
dc_hash['subject'] ||= []
dc_hash['subject'] << get_field_value(record[field.to_s])
end
[500..599].each do |field|
next if [506, 530, 540, 546].include?(field)
dc_hash['description'] ||= []
dc_hash['description'] << get_field_value(record[field.to_s])
end
dc_hash['publisher'] = get_field_value(record['260']['a']['b']) rescue nil
dc_hash['date'] = get_field_value(record['260']['c']) rescue nil
dc_hash['type'] = get_field_value(record['655'])
dc_hash['format'] = get_field_value(record['856']['q']) rescue nil
dc_hash['identifier'] = get_field_value(record['856']['u']) rescue nil
dc_hash['source'] = get_field_value(record['786']['o']['t']) rescue nil
dc_hash['language'] = get_field_value(record['546'])
dc_hash['relation'] = []
dc_hash['relation'] << get_field_value(record['530'])
[760..787].each do |field|
dc_hash['relation'] << get_field_value(record[field.to_s]['o']['t']) rescue nil
end
[651, 752].each do |field|
dc_hash['coverage'] ||= []
dc_hash['coverage'] << get_field_value(record[field.to_s])
end
[506, 540].each do |field|
dc_hash['rights'] ||= []
dc_hash['rights'] << get_field_value(record[field.to_s])
end
dc_hash.keys.each do |key|
dc_hash[key].flatten! if dc_hash[key].respond_to?(:flatten!)
dc_hash[key].compact! if dc_hash[key].respond_to?(:compact!)
end
dc_hash
end
|