Class: Relaton::Oiml::Docidentifier

Inherits:
Bib::Docidentifier show all
Defined in:
lib/relaton/oiml/docidentifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}, options = {}) ⇒ Docidentifier

Returns a new instance of Docidentifier.



6
7
8
9
10
11
# File 'lib/relaton/oiml/docidentifier.rb', line 6

def initialize(attrs = {}, options = {})
  pubid = attrs.is_a?(Hash) ? attrs.delete(:pubid) : nil
  attrs[:content] ||= pubid.to_s if pubid
  super
  @pubid = pubid if pubid
end

Instance Attribute Details

#pubidObject (readonly)

Returns the value of attribute pubid.



4
5
6
# File 'lib/relaton/oiml/docidentifier.rb', line 4

def pubid
  @pubid
end

Instance Method Details

#content=(value) ⇒ Object



13
14
15
16
17
18
# File 'lib/relaton/oiml/docidentifier.rb', line 13

def content=(value)
  super
  @pubid = ::Pubid::Oiml.parse(value) if value
rescue StandardError
  @pubid = nil
end

#remove_date!Object



24
25
26
# File 'lib/relaton/oiml/docidentifier.rb', line 24

def remove_date!
  @pubid&.date = nil
end

#remove_part!Object



20
21
22
# File 'lib/relaton/oiml/docidentifier.rb', line 20

def remove_part!
  @pubid&.part = nil
end

#to_all_parts!Object



28
29
30
# File 'lib/relaton/oiml/docidentifier.rb', line 28

def to_all_parts!
  @pubid&.all_parts = true
end