Class: RelatonCcsds::BibliographicItem

Inherits:
RelatonBib::BibliographicItem
  • Object
show all
Defined in:
lib/relaton_ccsds/bibliographic_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ BibliographicItem

Returns a new instance of BibliographicItem.

Parameters:

  • technology_area (String, nil)


6
7
8
9
# File 'lib/relaton_ccsds/bibliographic_item.rb', line 6

def initialize(**args)
  @technology_area = args.delete(:technology_area)
  super
end

Instance Attribute Details

#technology_areaObject (readonly)

Returns the value of attribute technology_area.



3
4
5
# File 'lib/relaton_ccsds/bibliographic_item.rb', line 3

def technology_area
  @technology_area
end

Instance Method Details

#ext_schemaString

Fetch flavor schema version

Returns:

  • (String)

    schema version



16
17
18
# File 'lib/relaton_ccsds/bibliographic_item.rb', line 16

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

#to_format(format) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/relaton_ccsds/bibliographic_item.rb', line 44

def to_format(format)
  return self unless format

  me = deep_clone
  me.link.select! { |l| l.type.casecmp(format).zero? }
  me if me.link.any?
end

#to_hash(embedded: false) ⇒ Hash

Returns:

  • (Hash)


35
36
37
38
39
40
41
42
# File 'lib/relaton_ccsds/bibliographic_item.rb', line 35

def to_hash(embedded: false)
  hash = super
  if technology_area
    hash["ext"] ||= {}
    hash["ext"]["technology_area"] = technology_area
  end
  hash
end

#to_xml(**opts) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/relaton_ccsds/bibliographic_item.rb', line 21

def to_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
  super do |builder|
    if opts[:bibdata] && (doctype || editorialgroup || technology_area)
      ext = builder.ext do |b|
        doctype&.to_xml b
        editorialgroup&.to_xml b
        b.send(:"technology-area", technology_area) if technology_area
      end
      ext["schema-version"] = ext_schema if !opts[:embedded] && respond_to?(:ext_schema) && ext_schema
    end
  end
end