Class: Pubid::Oiml::SupplementIdentifier

Inherits:
Identifier
  • Object
show all
Defined in:
lib/pubid/oiml/supplement_identifier.rb

Constant Summary

Constants inherited from Identifier

Identifier::OIML_TYPE_MAP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Identifier

from_hash, #to_urn

Instance Attribute Details

#requested_formatObject (readonly)

Returns the value of attribute requested_format.



48
49
50
# File 'lib/pubid/oiml/supplement_identifier.rb', line 48

def requested_format
  @requested_format
end

Instance Method Details

#base_identifier_from_kv(model, value) ⇒ Object



44
45
46
# File 'lib/pubid/oiml/supplement_identifier.rb', line 44

def base_identifier_from_kv(model, value)
  model.base_identifier = ::Pubid::Oiml::Identifier.from_hash(value) if value
end

#base_identifier_to_kv(model, doc) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/pubid/oiml/supplement_identifier.rb', line 34

def base_identifier_to_kv(model, doc)
  base = model.base_identifier
  return unless base

  doc.add_child(
    Lutaml::KeyValue::DataModel::Element.new("base_identifier",
                                             base.to_hash),
  )
end

#supplement_typeObject

Subclasses override this

Raises:

  • (NotImplementedError)


56
57
58
# File 'lib/pubid/oiml/supplement_identifier.rb', line 56

def supplement_type
  raise NotImplementedError, "Subclasses must implement supplement_type"
end

#to_s(format: nil, **opts) ⇒ Object



50
51
52
53
# File 'lib/pubid/oiml/supplement_identifier.rb', line 50

def to_s(format: nil, **opts)
  @requested_format = format
  render(format: :human, **opts)
end