Class: RelatonGb::GbBibliographicItem

Inherits:
RelatonIsoBib::IsoBibliographicItem
  • Object
show all
Defined in:
lib/relaton_gb/gb_bibliographic_item.rb

Overview

GB bibliographic item class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ GbBibliographicItem

Returns a new instance of GbBibliographicItem.



32
33
34
35
36
37
38
39
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 32

def initialize(**args)
  super
  args[:committee] && @committee = GbTechnicalCommittee.new(args[:committee])
  @ccs = args[:ccs].map { |c| c.is_a?(Cnccs::Ccs) ? c : Cnccs.fetch(c) }
  @gbtype = GbStandardType.new args[:gbtype]
  @type = args[:type]
  @gbplannumber = args[:gbplannumber] || structuredidentifier&.project_number
end

Instance Attribute Details

#ccsArray<Cnccs::Ccs> (readonly)

Returns:



24
25
26
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 24

def ccs
  @ccs
end

#committeeRelatonGb::GbTechnicalCommittee (readonly)



15
16
17
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 15

def committee
  @committee
end

#gbplannumberString (readonly)

Returns:

  • (String)


30
31
32
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 30

def gbplannumber
  @gbplannumber
end

#gbtypeRelatonGb::GbStandardType (readonly)



18
19
20
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 18

def gbtype
  @gbtype
end

#plan_numberString (readonly)

Returns:

  • (String)


27
28
29
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 27

def plan_number
  @plan_number
end

#topicString (readonly)

Returns:

  • (String)


21
22
23
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 21

def topic
  @topic
end

#typeString (readonly)

Returns:

  • (String)


30
31
32
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 30

def type
  @type
end

Instance Method Details

#inspectString

Returns:

  • (String)


64
65
66
67
68
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 64

def inspect
  "<#{self.class}:#{format('%#.14x', object_id << 1)}>"
  # "@fullIdentifier=\"#{@fetch&.shortref}\" "\
  # "@title=\"#{title}\">"
end

#makeid(id, attribute, _delim = "") ⇒ Object



75
76
77
78
79
80
81
82
83
84
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 75

def makeid(id, attribute, _delim = "")
  return nil if attribute && !@id_attribute

  id ||= @docidentifier.reject { |i| i.type == "DOI" }[0]
  idstr = id.id
  # if id.part_number&.size&.positive?
  #   idstr = idstr + "-#{id.part_number}"
  # end
  idstr.gsub(/\s/, "").strip
end

#to_hashHash

Returns:

  • (Hash)


54
55
56
57
58
59
60
61
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 54

def to_hash
  hash = super
  hash["ccs"] = single_element_array(ccs) if ccs&.any?
  hash["committee"] = committee.to_hash if committee
  hash["plannumber"] = gbplannumber if gbplannumber
  hash["gbtype"] = gbtype.to_hash
  hash
end

#to_sString

Returns:

  • (String)


71
72
73
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 71

def to_s
  inspect
end

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

Parameters:

  • builder (Nokogiri::XML::Builder) (defaults to: nil)

Returns:

  • (String)


43
44
45
46
47
48
49
50
51
# File 'lib/relaton_gb/gb_bibliographic_item.rb', line 43

def to_xml(builder = nil, **opts)
  if builder
    super(builder, **opts) { |xml| render_gbxml(xml) }
  else
    Nokogiri::XML::Builder.new(encoding: "UTF-8") do |bldr|
      super(bldr, **opts) { |xml| render_gbxml(xml) }
    end.doc.root.to_xml
  end
end