Class: RelatonBib::Contact

Inherits:
Object show all
Defined in:
lib/relaton_bib/contributor.rb

Overview

Contact class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, value:) ⇒ Contact

Returns a new instance of Contact.

Parameters:

  • type (String)

    allowed “phone”, “email” or “uri”

  • value (String)


92
93
94
95
# File 'lib/relaton_bib/contributor.rb', line 92

def initialize(type:, value:)
  @type  = type
  @value = value
end

Instance Attribute Details

#typeString (readonly)

Returns allowed “phone”, “email” or “uri”.

Returns:

  • (String)

    allowed “phone”, “email” or “uri”



85
86
87
# File 'lib/relaton_bib/contributor.rb', line 85

def type
  @type
end

#valueString (readonly)

Returns:

  • (String)


88
89
90
# File 'lib/relaton_bib/contributor.rb', line 88

def value
  @value
end

Instance Method Details

#to_asciibib(prefix = "", count = 1) ⇒ string

Parameters:

  • prefix (String) (defaults to: "")
  • count (Integer) (defaults to: 1)

    number of contacts

Returns:

  • (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_hashHash

Returns:

  • (Hash)


103
104
105
# File 'lib/relaton_bib/contributor.rb', line 103

def to_hash
  { type => value }
end

#to_xml(doc) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Document)


98
99
100
# File 'lib/relaton_bib/contributor.rb', line 98

def to_xml(doc)
  doc.send type, value
end