Class: ModsDisplay::Imprint
Instance Method Summary
collapse
#country_codes
Methods inherited from Field
#initialize, #label, #render_in, #to_html
Instance Method Details
#date_values(element, date_field_keys: %i[dateCreated dateCaptured dateValid dateModified copyrightDate])) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/mods_display/fields/imprint.rb', line 42
def date_values(element, date_field_keys: %i[dateCreated dateCaptured dateValid dateModified copyrightDate])
imprint = Stanford::Mods::Imprint.new(element)
date_field_keys.map do |date_field|
date_values = imprint.dates([date_field])
next if date_values.empty?
ModsDisplay::Values.new(
label: displayLabel(element) || pub_info_labels[date_field],
values: select_best_date(date_values)
)
end.compact
end
|
#fields ⇒ Object
7
8
9
|
# File 'lib/mods_display/fields/imprint.rb', line 7
def fields
collapse_fields(origin_info_data.flatten)
end
|
#origin_info_data ⇒ Object
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
|
# File 'lib/mods_display/fields/imprint.rb', line 11
def origin_info_data
@stanford_mods_elements.map do |origin_info_element|
return_fields = []
edition = edition_element(origin_info_element)
place = place_element(origin_info_element)
publisher = publisher_element(origin_info_element)
parts = parts_element(origin_info_element)
place_pub = compact_and_join_with_delimiter([place, publisher], ' : ')
edition_place = compact_and_join_with_delimiter([edition, place_pub], ' - ')
joined_place_parts = compact_and_join_with_delimiter([edition_place, parts], ', ')
unless joined_place_parts.empty?
return_fields << ModsDisplay::Values.new(
label: displayLabel(origin_info_element) || I18n.t('mods_display.imprint'),
values: [joined_place_parts]
)
end
return_fields.concat(date_values(origin_info_element))
other_pub_info(origin_info_element).each do |pub_info|
return_fields << ModsDisplay::Values.new(
label: displayLabel(origin_info_element) || pub_info_labels[pub_info.name.to_sym],
values: [element_text(pub_info)]
)
end
return_fields.compact
end
end
|
#other_pub_info(element) ⇒ Object
56
57
58
59
60
|
# File 'lib/mods_display/fields/imprint.rb', line 56
def other_pub_info(element)
element.children.select do |child|
pub_info_parts.include?(child.name.to_sym)
end
end
|
#place_terms(element) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/mods_display/fields/imprint.rb', line 62
def place_terms(element)
return [] unless element.respond_to?(:place) &&
element.place.respond_to?(:placeTerm)
if unencoded_place_terms?(element)
element.xpath('mods:place/mods:placeTerm', mods: MODS_NS).select do |term|
!term.attributes['type'].respond_to?(:value) ||
term.attributes['type'].value == 'text'
end.compact
else
element.xpath('mods:place/mods:placeTerm', mods: MODS_NS).map do |term|
next unless term.attributes['type'].respond_to?(:value) &&
term.attributes['type'].value == 'code' &&
term.attributes['authority'].respond_to?(:value) &&
term.attributes['authority'].value == 'marccountry' &&
country_codes.include?(term.text.strip)
term = term.clone
term.content = country_codes[term.text.strip]
term
end.compact
end
end
|
#unencoded_place_terms?(element) ⇒ Boolean
86
87
88
89
90
91
|
# File 'lib/mods_display/fields/imprint.rb', line 86
def unencoded_place_terms?(element)
element.xpath('mods:place/mods:placeTerm', mods: MODS_NS).any? do |term|
!term.attributes['type'].respond_to?(:value) ||
term.attributes['type'].value == 'text'
end
end
|