Class: RelatonBib::StructuredIdentifierCollection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
RelatonBib
Defined in:
lib/relaton_bib/structured_identifier.rb

Constant Summary

Constants included from RelatonBib

VERSION

Instance Method Summary collapse

Methods included from RelatonBib

array, format_date, grammar_hash, parse_date, parse_yaml

Methods included from Config

#configuration, #configure

Constructor Details

#initialize(collection) ⇒ StructuredIdentifierCollection

Returns a new instance of StructuredIdentifierCollection.

Parameters:



10
11
12
# File 'lib/relaton_bib/structured_identifier.rb', line 10

def initialize(collection)
  @collection = collection
end

Instance Method Details

#all_partsObject



44
45
46
# File 'lib/relaton_bib/structured_identifier.rb', line 44

def all_parts
  @collection.each &:all_parts
end

#presence?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/relaton_bib/structured_identifier.rb', line 48

def presence?
  any?
end

#remove_dateObject

remoe year from docnumber



36
37
38
# File 'lib/relaton_bib/structured_identifier.rb', line 36

def remove_date
  @collection.each &:remove_date
end

#remove_partObject



40
41
42
# File 'lib/relaton_bib/structured_identifier.rb', line 40

def remove_part
  @collection.each &:remove_part
end

#to_asciibib(prefix = "") ⇒ String

Parameters:

  • prefix (String) (defaults to: "")

Returns:

  • (String)


26
27
28
29
30
31
32
33
# File 'lib/relaton_bib/structured_identifier.rb', line 26

def to_asciibib(prefix = "")
  pref = prefix.empty? ? prefix : prefix + "."
  pref += "structured_identifier"
  @collection.reduce("") do |out, si|
    out += "#{pref}::\n" if @collection.size > 1
    out + si.to_asciibib(pref)
  end
end

#to_hashArray<Hash>

Returns:



20
21
22
# File 'lib/relaton_bib/structured_identifier.rb', line 20

def to_hash
  single_element_array @collection
end

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


15
16
17
# File 'lib/relaton_bib/structured_identifier.rb', line 15

def to_xml(builder)
  @collection.each { |si| si.to_xml builder }
end