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.
83 84 85 86 |
# File 'lib/relaton_bib/contributor.rb', line 83 def initialize(type:, value:) @type = type @value = value end |
Instance Attribute Details
#type ⇒ String (readonly)
Returns allowed “phone”, “email” or “uri”.
76 77 78 |
# File 'lib/relaton_bib/contributor.rb', line 76 def type @type end |
#value ⇒ String (readonly)
79 80 81 |
# File 'lib/relaton_bib/contributor.rb', line 79 def value @value end |
Instance Method Details
#to_asciibib(prefix = "", count = 1) ⇒ string
101 102 103 104 105 106 107 |
# File 'lib/relaton_bib/contributor.rb', line 101 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.value:: #{value}\n" out end |
#to_hash ⇒ Hash
94 95 96 |
# File 'lib/relaton_bib/contributor.rb', line 94 def to_hash { "type" => type, "value" => value } end |
#to_xml(doc) ⇒ Object
89 90 91 |
# File 'lib/relaton_bib/contributor.rb', line 89 def to_xml(doc) doc.send type, value end |