Class: IsoBibItem::Address

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

Overview

Address class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(street:, city:, state: nil, country:, postcode: nil) ⇒ Address

Returns a new instance of Address.

Parameters:

  • street (Array<String>)
  • city (String)
  • state (String) (defaults to: nil)
  • country (String)
  • postcode (String) (defaults to: nil)


28
29
30
31
32
33
34
# File 'lib/iso_bib_item/contributor.rb', line 28

def initialize(street:, city:, state: nil, country:, postcode: nil)
  @street   = street
  @city     = city
  @state    = state
  @country  = country
  @postcode = postcode
end

Instance Attribute Details

#cityString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/iso_bib_item/contributor.rb', line 12

def city
  @city
end

#countryString (readonly)

Returns:

  • (String)


18
19
20
# File 'lib/iso_bib_item/contributor.rb', line 18

def country
  @country
end

#postcodeString, NilClass (readonly)

Returns:

  • (String, NilClass)


21
22
23
# File 'lib/iso_bib_item/contributor.rb', line 21

def postcode
  @postcode
end

#stateString, NilClass (readonly)

Returns:

  • (String, NilClass)


15
16
17
# File 'lib/iso_bib_item/contributor.rb', line 15

def state
  @state
end

#streetArray<String> (readonly)

Returns:



9
10
11
# File 'lib/iso_bib_item/contributor.rb', line 9

def street
  @street
end

Instance Method Details

#to_xml(doc) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Document)


37
38
39
40
41
42
43
44
45
# File 'lib/iso_bib_item/contributor.rb', line 37

def to_xml(doc)
  doc.address do
    street.each { |str| doc.street str }
    doc.city city
    doc.state state if state
    doc.country country
    doc.postcode postcode if postcode
  end
end