Class: RelatonBib::Contact
Overview
Contact class.
Instance Attribute Summary collapse
-
#type ⇒ String
readonly
Allowed “phone”, “email” or “uri”.
- #value ⇒ String readonly
Instance Method Summary collapse
-
#initialize(type:, value:) ⇒ Contact
constructor
A new instance of Contact.
- #to_asciibib(prefix = "", count = 1) ⇒ string
- #to_hash ⇒ Hash
- #to_xml(doc) ⇒ Object
Constructor Details
#initialize(type:, value:) ⇒ Contact
Returns a new instance of Contact.
92 93 94 95 |
# File 'lib/relaton_bib/contributor.rb', line 92 def initialize(type:, value:) @type = type @value = value end |
Instance Attribute Details
#type ⇒ String (readonly)
Returns allowed “phone”, “email” or “uri”.
85 86 87 |
# File 'lib/relaton_bib/contributor.rb', line 85 def type @type end |
#value ⇒ String (readonly)
88 89 90 |
# File 'lib/relaton_bib/contributor.rb', line 88 def value @value end |
Instance Method Details
#to_asciibib(prefix = "", count = 1) ⇒ string
110 111 112 113 114 115 116 |
# File 'lib/relaton_bib/contributor.rb', line 110 def to_asciibib(prefix = "", count = 1) pref = prefix.empty? ? prefix : "#{prefix}." out = count > 1 ? "#{pref}contact::\n" : "" # out += "#{pref}contact.type:: #{type}\n" out += "#{pref}contact.#{type}:: #{value}\n" out end |
#to_hash ⇒ Hash
103 104 105 |
# File 'lib/relaton_bib/contributor.rb', line 103 def to_hash { type => value } end |
#to_xml(doc) ⇒ Object
98 99 100 |
# File 'lib/relaton_bib/contributor.rb', line 98 def to_xml(doc) doc.send type, value end |