Class: RelatonBib::OrgIdentifier
- Defined in:
- lib/relaton_bib/organization.rb
Overview
Organization identifier.
Instance Attribute Summary collapse
- #type ⇒ String readonly
- #value ⇒ String readonly
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(type, value) ⇒ OrgIdentifier
constructor
A new instance of OrgIdentifier.
- #to_asciibib(prefix = "", count = 1) ⇒ String
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(type, value) ⇒ OrgIdentifier
Returns a new instance of OrgIdentifier.
19 20 21 22 23 24 25 26 |
# File 'lib/relaton_bib/organization.rb', line 19 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)
12 13 14 |
# File 'lib/relaton_bib/organization.rb', line 12 def type @type end |
#value ⇒ String (readonly)
15 16 17 |
# File 'lib/relaton_bib/organization.rb', line 15 def value @value end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 |
# File 'lib/relaton_bib/organization.rb', line 28 def ==(other) type == other.type && value == other.value end |
#to_asciibib(prefix = "", count = 1) ⇒ String
45 46 47 48 49 50 51 |
# File 'lib/relaton_bib/organization.rb', line 45 def to_asciibib(prefix = "", count = 1) pref = prefix.empty? ? prefix : "#{prefix}." out = count > 1 ? "#{pref}identifier::\n" : "" out += "#{pref}identifier.type:: #{type}\n" out += "#{pref}identifier.value:: #{value}\n" out end |
#to_hash ⇒ Hash
38 39 40 |
# File 'lib/relaton_bib/organization.rb', line 38 def to_hash { "type" => type, "id" => value } end |
#to_xml(builder) ⇒ Object
33 34 35 |
# File 'lib/relaton_bib/organization.rb', line 33 def to_xml(builder) builder.identifier(value, type: type) end |