Class: RelatonBib::OrgIdentifier
- Inherits:
-
Object
- Object
- RelatonBib::OrgIdentifier
- Defined in:
- lib/relaton_bib/organization.rb
Overview
Organization identifier.
Constant Summary collapse
- ORCID =
"orcid"
- URI =
"uri"
Instance Attribute Summary collapse
- #type ⇒ String readonly
- #value ⇒ String readonly
Instance Method Summary collapse
-
#initialize(type, value) ⇒ OrgIdentifier
constructor
A new instance of OrgIdentifier.
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(type, value) ⇒ OrgIdentifier
Returns a new instance of OrgIdentifier.
24 25 26 27 28 29 30 31 |
# File 'lib/relaton_bib/organization.rb', line 24 def initialize(type, value) unless [ORCID, URI].include? type raise ArgumentError, 'Invalid type. It should be "orsid" or "uri".' end @type = type @value = value end |
Instance Attribute Details
#type ⇒ String (readonly)
17 18 19 |
# File 'lib/relaton_bib/organization.rb', line 17 def type @type end |
#value ⇒ String (readonly)
20 21 22 |
# File 'lib/relaton_bib/organization.rb', line 20 def value @value end |
Instance Method Details
#to_hash ⇒ Hash
39 40 41 |
# File 'lib/relaton_bib/organization.rb', line 39 def to_hash { "type" => type, "id" => value } end |
#to_xml(builder) ⇒ Object
34 35 36 |
# File 'lib/relaton_bib/organization.rb', line 34 def to_xml(builder) builder.identifier(value, type: type) end |