Class: Relaton::Plateau::BibItem

Inherits:
RelatonBib::BibliographicItem
  • Object
show all
Defined in:
lib/relaton/plateau/bibitem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ BibItem

Returns a new instance of BibItem.



16
17
18
19
20
21
# File 'lib/relaton/plateau/bibitem.rb', line 16

def initialize(**args)
  @cover = args.delete(:cover)
  @filesize = args.delete(:filesize)
  @stagename = args.delete(:stagename)
  super(**args)
end

Instance Attribute Details

#coverRelaton::Plateau::Cover? (readonly)

Returns:



8
9
10
# File 'lib/relaton/plateau/bibitem.rb', line 8

def cover
  @cover
end

#filesizeInteger?

Returns:

  • (Integer, nil)


14
15
16
# File 'lib/relaton/plateau/bibitem.rb', line 14

def filesize
  @filesize
end

#stagenameRelaton::Plateau::Stagename? (readonly)

Returns:



11
12
13
# File 'lib/relaton/plateau/bibitem.rb', line 11

def stagename
  @stagename
end

Instance Method Details

#ext_schemaString

Fetch flavor schema version

Returns:

  • (String)

    schema version



28
29
30
# File 'lib/relaton/plateau/bibitem.rb', line 28

def ext_schema
  @ext_schema ||= schema_versions["relaton-model-plateau"]
end

#to_all_editions(hits) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/relaton/plateau/bibitem.rb', line 75

def to_all_editions(hits)
  return self if hits.size < 2

  me = deep_clone
  me.docidentifier.each(&:remove_edition)
  me.id.sub!(/#{Regexp.escape(me.edition.content)}$/, "")
  me.instance_variable_set :@edition, nil
  me.date = []
  me.instance_variable_set :@link, []
  me.filesize = nil
  hits.each do |h|
    me.relation << RelatonBib::DocumentRelation.new(type: "hasEdition", bibitem: h.bibitem)
  end
  me
end

#to_asciibib(prefix = "") ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/relaton/plateau/bibitem.rb', line 66

def to_asciibib(prefix = "")
  pref = prefix.empty? ? "" : "#{prefix}."
  output = super
  output += stagename.to_asciibib prefix if stagename
  output += cover.to_asciibib prefix if cover
  output += "#{pref}filesize:: #{filesize}\n" if filesize
  output
end

#to_hashObject



55
56
57
58
59
60
61
62
63
64
# File 'lib/relaton/plateau/bibitem.rb', line 55

def to_hash
  hash = super
  return hash unless has_ext?

  hash["ext"] ||= {}
  hash["ext"]["stagename"] = stagename.to_hash if stagename
  hash["ext"]["cover"] = cover.to_hash if cover
  hash["ext"]["filesize"] = filesize if filesize
  hash
end

#to_xml(**opts) ⇒ Object

Parameters:

  • opts (Hash)

Options Hash (**opts):

  • :builder (Nokogiri::XML::Builder)

    XML builder

  • bibdata (Boolean)
  • :date_format (Symbol, nil) — default: :short

    , :full

  • :lang (String)

    language



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/relaton/plateau/bibitem.rb', line 37

def to_xml(**opts)
  super do |builder|
    if opts[:bibdata] && has_ext?
      ext = builder.ext do |b|
        doctype&.to_xml b
        b.subdoctype subdoctype if subdoctype
        editorialgroup&.to_xml b
        ics.each { |i| b.ics i }
        structuredidentifier&.to_xml b
        stagename&.to_xml b
        cover&.to_xml b
        b.filesize filesize if filesize
      end
      ext["schema-version"] = ext_schema if !opts[:embedded] && respond_to?(:ext_schema) && ext_schema
    end
  end
end