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
- #==(other) ⇒ Object
-
#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.
103 104 105 106 107 |
# File 'lib/relaton_bib/contributor.rb', line 103 def initialize(type:, value:, subtype: nil) @type = type @subtype = subtype @value = value end |
Instance Attribute Details
#subtype ⇒ String? (readonly)
94 95 96 |
# File 'lib/relaton_bib/contributor.rb', line 94 def subtype @subtype end |
#type ⇒ String (readonly)
Returns allowed “phone”, “email” or “uri”.
91 92 93 |
# File 'lib/relaton_bib/contributor.rb', line 91 def type @type end |
#value ⇒ String (readonly)
97 98 99 |
# File 'lib/relaton_bib/contributor.rb', line 97 def value @value end |
Instance Method Details
#==(other) ⇒ Object
109 110 111 |
# File 'lib/relaton_bib/contributor.rb', line 109 def ==(other) type == other.type && subtype == other.subtype && value == other.value end |
#to_asciibib(prefix = "", count = 1) ⇒ string
129 130 131 132 133 134 135 |
# File 'lib/relaton_bib/contributor.rb', line 129 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
120 121 122 123 124 |
# File 'lib/relaton_bib/contributor.rb', line 120 def to_hash hash = { type => value } hash["type"] = subtype if subtype hash end |
#to_xml(builder) ⇒ Object
114 115 116 117 |
# File 'lib/relaton_bib/contributor.rb', line 114 def to_xml(builder) node = builder.send type, value node["type"] = subtype if subtype end |