Class: RelatonIsoBib::IsoBibliographicItem

Inherits:
RelatonBib::BibliographicItem
  • Object
show all
Defined in:
lib/relaton_iso_bib/iso_bibliographic_item.rb

Overview

Bibliographic item.

Constant Summary collapse

TYPES =
%w[
  international-standard technical-specification technical-report
  publicly-available-specification international-workshop-agreement guide
  amendment technical-corrigendum
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ IsoBibliographicItem

Returns a new instance of IsoBibliographicItem.

Parameters:

  • edition (String)
  • docnumber (String, NilClass)
  • language (Array<String>)
  • script (Arrra<String>)
  • docstatus (RelatonBib::DocumentStatus, NilClass)
  • type (String, NilClass)
  • formattedref (RelatonBib::FormattedRef, NilClass)
  • version (RelatonBib::BibliographicItem::Version, NilClass)
  • biblionote (Array<RelatonBib::BiblioNote>)
  • series (Array<RelatonBib::Series>)
  • medium (RelatonBib::Medium, NilClas)
  • place (Array<String>)
  • extent (Array<Relaton::BibItemLocality>)
  • accesslocation (Array<String>)
  • classification (RelatonBib::Classification, NilClass)
  • validity (RelatonBib:Validity, NilClass)
  • docid (Array<RelatonBib::DocumentIdentifier>)
  • structuredidentifier (RelatonIsoBib::StructuredIdentifier)
  • stagename (String, NilClass)
  • title (Array<Hash>)
  • editorialgroup (Hash, RelatonIsoBib::EditorialGroup)
  • ics (Array<Hash>)
  • date (Array<Hash>)
  • abstract (Array<Hash>)
  • contributor (Array<Hash>)
  • copyright (Hash)
  • link (Array<Hash, RelatonBib::TypedUri>)
  • relation (Array<Hash>)
  • workgrpup (Hash)

    a customizable set of options

  • technical_committee (Hash)

    a customizable set of options

  • entity (Hash)

    a customizable set of options

  • owner (Hash)

    a customizable set of options

Raises:

  • (ArgumentError)


125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 125

def initialize(**args)
  check_doctype args[:doctype]

  super_args = args.select do |k|
    %i[id docnumber language script docstatus date abstract contributor
       edition version relation biblionote series medium place copyright
       link fetched docid formattedref extent accesslocation classification
       validity doctype keyword].include? k
  end
  super super_args

  @type = args[:type] || "standard"

  @title = args.fetch(:title, []).map do |t|
    if t.is_a? Hash
      # a + typed_titles(t)
      RelatonBib::TypedTitleString.new t
    else
      t
    end
  end

  if args[:editorialgroup]
    @editorialgroup = if args[:editorialgroup].is_a?(Hash)
                        EditorialGroup.new(args[:editorialgroup])
                      else args[:editorialgroup]
                      end
  end

  @structuredidentifier = args[:structuredidentifier]
  # @doctype = args[:doctype] || "international-standard"
  @ics = args.fetch(:ics, []).map { |i| i.is_a?(Hash) ? Ics.new(i) : i }
  @stagename = args[:stagename]
  @id_attribute = true
end

Instance Attribute Details

#doctypeString, NilClass (readonly)

Returns:

  • (String, NilClass)


37
38
39
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 37

def doctype
  @doctype
end

#editorialgroupRelatonIsoBib::EditorialGroup (readonly)



40
41
42
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 40

def editorialgroup
  @editorialgroup
end

#icsArray<RelatonIsoBib::Ics> (readonly)



43
44
45
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 43

def ics
  @ics
end

#stagenameString, NilClass (readonly)

Returns:

  • (String, NilClass)


37
38
39
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 37

def stagename
  @stagename
end

#structuredidentifierRelatonIsoBib::StructuredIdentifier (readonly)



31
32
33
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 31

def structuredidentifier
  @structuredidentifier
end

#titleArray<RelatonBib::TypedTitleString> (readonly)

Returns:

  • (Array<RelatonBib::TypedTitleString>)


# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 33

Instance Method Details

#to_asciibib(prefix = "") ⇒ String

Parameters:

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

Returns:

  • (String)


197
198
199
200
201
202
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 197

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

#to_hashHash

Returns:

  • (Hash)


189
190
191
192
193
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 189

def to_hash
  hash = super
  hash["stagename"] = stagename if stagename
  hash
end

#to_xml(builder = nil, **opts) ⇒ String

Returns:

  • (String)


162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/relaton_iso_bib/iso_bibliographic_item.rb', line 162

def to_xml(builder = nil, **opts)
  super builder, **opts do |b|
    if opts[:bibdata] && (doctype || respond_to?(:committee) && committee ||
      editorialgroup || ics.any? || structuredidentifier || stagename ||
      block_given?)
      b.ext do
        b.doctype doctype if doctype
        b.docsubtype docsubtype if respond_to?(:docsubtype) && docsubtype
        # GB renders gbcommittee elements istead of an editorialgroup
        if respond_to? :committee
          committee&.to_xml b
        else
          editorialgroup&.to_xml b
        end
        ics.each { |i| i.to_xml b }
        structuredidentifier&.to_xml b
        b.stagename stagename if stagename
        yield b if block_given?
      end
    end
  end
end