Class: LUSI::API::Person::PersonAddress

Inherits:
Object
  • Object
show all
Defined in:
lib/lusi_api/person/student.rb

Overview

Represents a person’s postal address

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml = nil, lookup = nil, address_type: nil, address_line_1: nil, address_line_2: nil, address_line_3: nil, address_line_4: nil, address_line_5: nil, post_code: nil, country: nil) ⇒ void

Initialises a PersonAddress instance

Parameters:

  • xml (Nokogiri::XML::Document, Nokogiri::XML::Node) (defaults to: nil)

    the parsed XML root of the address

  • lookup (LUSI::API::Core::Lookup::LookupService, nil) (defaults to: nil)

    the lookup service for object resolution

  • address_type (String, nil) (defaults to: nil)

    the default address type

  • address_line_1 (String, nil) (defaults to: nil)

    the default first address line

  • address_line_2 (String, nil) (defaults to: nil)

    the default second address line

  • address_line_3 (String, nil) (defaults to: nil)

    the default third address line

  • address_line_4 (String, nil) (defaults to: nil)

    the default fourth address line

  • address_line_5 (String, nil) (defaults to: nil)

    the default fifth address line

  • post_code (String, nil) (defaults to: nil)

    the default postal or zip code

  • country (LUSI::API::Country::AddressCountry, nil) (defaults to: nil)

    the default country



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/lusi_api/person/student.rb', line 99

def initialize(xml = nil, lookup = nil, address_type: nil, address_line_1: nil, address_line_2: nil,
               address_line_3: nil, address_line_4: nil, address_line_5: nil, post_code: nil, country: nil)
  @address_type = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:AddressType', address_type)
  @address_line_1 = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:AddressLine1', address_line_1)
  @address_line_2 = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:AddressLine2', address_line_2)
  @address_line_3 = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:AddressLine3', address_line_3)
  @address_line_4 = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:AddressLine4', address_line_4)
  @address_line_5 = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:AddressLine5', address_line_5)
  @post_code = LUSI::API::Core::XML.xml_content_at(xml, 'xmlns:PostCode', post_code)
  @country = LUSI::API::Core::XML.lookup(xml, lookup, :address_country, 'xmlns:Country/xmlns:Identity', country)
end

Instance Attribute Details

#address_line_1String?

Returns the first address line.

Returns:

  • (String, nil)

    the first address line



61
62
63
# File 'lib/lusi_api/person/student.rb', line 61

def address_line_1
  @address_line_1
end

#address_line_2String?

Returns the second address line.

Returns:

  • (String, nil)

    the second address line



65
66
67
# File 'lib/lusi_api/person/student.rb', line 65

def address_line_2
  @address_line_2
end

#address_line_3String?

Returns the third address line.

Returns:

  • (String, nil)

    the third address line



69
70
71
# File 'lib/lusi_api/person/student.rb', line 69

def address_line_3
  @address_line_3
end

#address_line_4String?

Returns the fourth address line.

Returns:

  • (String, nil)

    the fourth address line



73
74
75
# File 'lib/lusi_api/person/student.rb', line 73

def address_line_4
  @address_line_4
end

#address_line_5String?

Returns the fifth address line.

Returns:

  • (String, nil)

    the fifth address line



77
78
79
# File 'lib/lusi_api/person/student.rb', line 77

def address_line_5
  @address_line_5
end

#address_typeString?

Returns the address type (e.g. ‘Termtime Address’).

Returns:

  • (String, nil)

    the address type (e.g. ‘Termtime Address’)



57
58
59
# File 'lib/lusi_api/person/student.rb', line 57

def address_type
  @address_type
end

#countryLUSI::API::Person::AddressCountry?

Returns the country.

Returns:

  • (LUSI::API::Person::AddressCountry, nil)

    the country



85
86
87
# File 'lib/lusi_api/person/student.rb', line 85

def country
  @country
end

#post_codeString?

Returns the postal or zip code.

Returns:

  • (String, nil)

    the postal or zip code



81
82
83
# File 'lib/lusi_api/person/student.rb', line 81

def post_code
  @post_code
end

Instance Method Details

#to_s(sep = nil) ⇒ String

Returns a string representation of the PersonAddress instance

Returns:

  • (String)

    the string representation of the PersonAddress instance



113
114
115
116
117
118
119
120
121
122
# File 'lib/lusi_api/person/student.rb', line 113

def to_s(sep = nil)
  sep ||= ', '
  fields = []
  [@address_type, @address_line_1, @address_line_2, @address_line_3, @address_line_4, @address_line_5,
   @post_code, @country].each do |field|
    field_s = field.to_s
    fields.push(field_s) unless field_s.nil? || field_s.empty?
  end
  fields.join(sep)
end