Class: Relaton::Iho::Docidentifier

Inherits:
Bib::Docidentifier
  • Object
show all
Defined in:
lib/relaton/iho/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/iho/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/iho/docidentifier.rb', line 4

def pubid
  @pubid
end

Instance Method Details

#content=(value) ⇒ Object



13
14
15
16
# File 'lib/relaton/iho/docidentifier.rb', line 13

def content=(value)
  super
  @pubid = ::Pubid::Iho::Identifier.parse(value) if value
end

#remove_date!Object



26
27
28
# File 'lib/relaton/iho/docidentifier.rb', line 26

def remove_date!
  @pubid&.year = nil
end

#remove_part!Object



22
23
24
# File 'lib/relaton/iho/docidentifier.rb', line 22

def remove_part!
  @pubid&.part = nil
end

#to_all_parts!Object



30
31
32
# File 'lib/relaton/iho/docidentifier.rb', line 30

def to_all_parts!
  @pubid&.all_parts = true
end

#to_hObject



18
19
20
# File 'lib/relaton/iho/docidentifier.rb', line 18

def to_h
  @pubid&.to_h || super
end