Class: EpoOps::Factories::NameAndAddressFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/epo_ops/factories/name_and_address_factory.rb

Overview

Parses the addressbook data from EPO Ops into an ‘NameAndAddress’ object

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_data) ⇒ NameAndAddressFactory

Returns a new instance of NameAndAddressFactory.



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/epo_ops/factories/name_and_address_factory.rb', line 35

def initialize(raw_data)
  @raw_data = raw_data
  @name = raw_data['name']
  if raw_data['address'].is_a? Hash
    @address_1    = raw_data['address']['address_1']
    @address_2    = raw_data['address']['address_2']
    @address_3    = raw_data['address']['address_3']
    @address_4    = raw_data['address']['address_4']
    @address_5    = raw_data['address']['address_5']
    @country_code = raw_data['address']['country']
  end
  @cdsid = raw_data['cdsid']
end

Instance Attribute Details

#address_1Object (readonly)

Returns the value of attribute address_1.



25
26
27
# File 'lib/epo_ops/factories/name_and_address_factory.rb', line 25

def address_1
  @address_1
end

#address_2Object (readonly)

Returns the value of attribute address_2.



25
26
27
# File 'lib/epo_ops/factories/name_and_address_factory.rb', line 25

def address_2
  @address_2
end

#address_3Object (readonly)

Returns the value of attribute address_3.



25
26
27
# File 'lib/epo_ops/factories/name_and_address_factory.rb', line 25

def address_3
  @address_3
end

#address_4Object (readonly)

Returns the value of attribute address_4.



25
26
27
# File 'lib/epo_ops/factories/name_and_address_factory.rb', line 25

def address_4
  @address_4
end

#address_5Object (readonly)

Returns the value of attribute address_5.



25
26
27
# File 'lib/epo_ops/factories/name_and_address_factory.rb', line 25

def address_5
  @address_5
end

#cdsidObject (readonly)

Returns the value of attribute cdsid.



25
26
27
# File 'lib/epo_ops/factories/name_and_address_factory.rb', line 25

def cdsid
  @cdsid
end

#country_codeObject (readonly)

Returns the value of attribute country_code.



25
26
27
# File 'lib/epo_ops/factories/name_and_address_factory.rb', line 25

def country_code
  @country_code
end

#nameObject (readonly)

Returns the value of attribute name.



25
26
27
# File 'lib/epo_ops/factories/name_and_address_factory.rb', line 25

def name
  @name
end

#raw_dataObject (readonly)

Returns the value of attribute raw_data.



25
26
27
# File 'lib/epo_ops/factories/name_and_address_factory.rb', line 25

def raw_data
  @raw_data
end

Class Method Details

.build(raw_data) ⇒ EpoOps::NameAndAddress

Returns NameAndAddress filled with parsed data.

Parameters:

  • raw_data (Hash)

    raw addressbook data as retrieved included in Epo Ops biblio data

Returns:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/epo_ops/factories/name_and_address_factory.rb', line 9

def build(raw_data)
  factory = new(raw_data)

  EpoOps::NameAndAddress.new(
      factory.name,
      factory.address_1,
      factory.address_2,
      factory.address_3,
      factory.address_4,
      factory.address_5,
      factory.country_code,
      factory.cdsid
  )
end