Class: ModsDisplay::RelatedItemConcerns::RelatedItemValue

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/mods_display/related_item_concerns.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_values(values) ⇒ Object



59
60
61
# File 'lib/mods_display/related_item_concerns.rb', line 59

def self.for_values(values)
  values.map { |value| new(value) }
end

Instance Method Details

#collection?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/mods_display/related_item_concerns.rb', line 12

def collection?
  @collection ||= typeOfResource_nodeset.first&.get_attribute('collection') == 'yes'
end

#constituent?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/mods_display/related_item_concerns.rb', line 16

def constituent?
  @constituent ||= type_attribute == 'constituent'
end

#host?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/mods_display/related_item_concerns.rb', line 20

def host?
  @host ||= type_attribute == 'host'
end

#location?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
# File 'lib/mods_display/related_item_concerns.rb', line 24

def location?
  @location ||= !collection? &&
                !reference? &&
                location_nodeset.length.positive? &&
                titleInfo_nodeset.empty?
end

#location_nodesetObject



39
40
41
# File 'lib/mods_display/related_item_concerns.rb', line 39

def location_nodeset
  @location_nodeset ||= xpath('mods:location', mods: MODS_NS)
end

#location_url_nodesetObject



43
44
45
# File 'lib/mods_display/related_item_concerns.rb', line 43

def location_url_nodeset
  @location_url_nodeset ||= xpath('mods:location/mods:url', mods: MODS_NS)
end

#note_nodesetObject



51
52
53
# File 'lib/mods_display/related_item_concerns.rb', line 51

def note_nodeset
  @note_nodeset ||= xpath('mods:note', mods: MODS_NS)
end

#reference?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/mods_display/related_item_concerns.rb', line 31

def reference?
  @reference ||= !collection? && type_attribute == 'isReferencedBy'
end

#titleInfo_nodesetObject



47
48
49
# File 'lib/mods_display/related_item_concerns.rb', line 47

def titleInfo_nodeset
  @titleInfo_nodeset ||= xpath('mods:titleInfo', mods: MODS_NS)
end

#type_attributeObject



55
56
57
# File 'lib/mods_display/related_item_concerns.rb', line 55

def type_attribute
  @type_attribute ||= get_attribute('type')
end

#typeOfResource_nodesetObject



35
36
37
# File 'lib/mods_display/related_item_concerns.rb', line 35

def typeOfResource_nodeset
  @typeOfResource_nodeset ||= xpath('mods:typeOfResource', mods: MODS_NS)
end