Class: RelatonBib::Contact
Overview
Contact class.
Instance Attribute Summary collapse
- #subtype ⇒ String? readonly
-
#type ⇒ String
readonly
Allowed “phone”, “email” or “uri”.
- #value ⇒ String readonly
Instance Method Summary collapse
-
#initialize(type:, value:, subtype: nil) ⇒ Contact
constructor
A new instance of Contact.
- #to_asciibib(prefix = "", count = 1) ⇒ string
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(type:, value:, subtype: nil) ⇒ Contact
Returns a new instance of Contact.
97 98 99 100 101 |
# File 'lib/relaton_bib/contributor.rb', line 97 def initialize(type:, value:, subtype: nil) @type = type @subtype = subtype @value = value end |
Instance Attribute Details
#subtype ⇒ String? (readonly)
88 89 90 |
# File 'lib/relaton_bib/contributor.rb', line 88 def subtype @subtype end |
#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)
91 92 93 |
# File 'lib/relaton_bib/contributor.rb', line 91 def value @value end |
Instance Method Details
#to_asciibib(prefix = "", count = 1) ⇒ string
119 120 121 122 123 124 125 |
# File 'lib/relaton_bib/contributor.rb', line 119 def to_asciibib(prefix = "", count = 1) pref = prefix.empty? ? prefix : "#{prefix}." out = count > 1 ? "#{pref}contact::\n" : "" out += "#{pref}contact.#{type}:: #{value}\n" out += "#{pref}contact.type:: #{subtype}\n" if subtype out end |
#to_hash ⇒ Hash
110 111 112 113 114 |
# File 'lib/relaton_bib/contributor.rb', line 110 def to_hash hash = { type => value } hash["type"] = subtype if subtype hash end |
#to_xml(builder) ⇒ Object
104 105 106 107 |
# File 'lib/relaton_bib/contributor.rb', line 104 def to_xml(builder) node = builder.send type, value node["type"] = subtype if subtype end |