Class: RelatonOgc::OgcBibliographicItem

Inherits:
RelatonBib::BibliographicItem
  • Object
show all
Defined in:
lib/relaton_ogc/ogc_bibliographic_item.rb

Constant Summary collapse

TYPES =
%w[
  abstract-specification-topic best-practice
  change-request-supporting-document
  community-practice community-standard discussion-paper engineering-report
  other policy reference-model release-notes standard user-guide white-paper
  test-suite
].freeze
SUBTYPES =
%w[
  conceptual-model conceptual-model-and-encoding
  conceptual-model-and-implementation encoding extension implementation
  profile profile-with-extension general
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ OgcBibliographicItem

Returns a new instance of OgcBibliographicItem.

Parameters:

  • docsubtype (String)


21
22
23
24
25
26
27
28
29
30
# File 'lib/relaton_ogc/ogc_bibliographic_item.rb', line 21

def initialize(**args)
  if args[:docsubtype] && !SUBTYPES.include?(args[:docsubtype])
    warn "[relaton-ogc] WARNING: invalid document "\
    "subtype: #{args[:docsubtype]}"
  end

  @docsubtype = args.delete :docsubtype
  # @doctype = args.delete :doctype
  super
end

Instance Attribute Details

#docsubtypeString (readonly)

Returns:

  • (String)


18
19
20
# File 'lib/relaton_ogc/ogc_bibliographic_item.rb', line 18

def docsubtype
  @docsubtype
end

Instance Method Details

#to_asciibib(prefix = "") ⇒ String

Parameters:

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

Returns:

  • (String)


58
59
60
61
62
63
# File 'lib/relaton_ogc/ogc_bibliographic_item.rb', line 58

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

#to_hashHash

Returns:

  • (Hash)


33
34
35
36
37
# File 'lib/relaton_ogc/ogc_bibliographic_item.rb', line 33

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

#to_xml(**opts) ⇒ String

Returns XML.

Parameters:

  • opts (Hash)

Options Hash (**opts):

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

    XML builder

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

    , :full

  • :lang (String, Symbol)

    language

Returns:

  • (String)

    XML



45
46
47
48
49
50
51
52
53
54
# File 'lib/relaton_ogc/ogc_bibliographic_item.rb', line 45

def to_xml(**opts)
  super **opts do |b|
    b.ext do
      b.doctype doctype if doctype
      b.docsubtype docsubtype if docsubtype
      editorialgroup&.to_xml b
      ics.each { |i| i.to_xml b }
    end
  end
end