class LUSI::API::Person::PersonAddress

Represents a person's postal address

Attributes

address_line_1[RW]

@!attribute [rw] address_line_1

@return [String, nil] the first address line
address_line_2[RW]

@!attribute [rw] address_line_2

@return [String, nil] the second address line
address_line_3[RW]

@!attribute [rw] address_line_3

@return [String, nil] the third address line
address_line_4[RW]

@!attribute [rw] address_line_4

@return [String, nil] the fourth address line
address_line_5[RW]

@!attribute [rw] address_line_5

@return [String, nil] the fifth address line
address_type[RW]

@!attribute [rw] address_type

@return [String, nil] the address type (e.g. 'Termtime Address')
country[RW]

@!attribute [rw] country

@return [LUSI::API::Person::AddressCountry, nil] the country
post_code[RW]

@!attribute [rw] post_code

@return [String, nil] the postal or zip code

Public Class Methods

new(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) click to toggle source

Initialises a PersonAddress instance @param xml [Nokogiri::XML::Document, Nokogiri::XML::Node] the parsed XML root of the address @param lookup [LUSI::API::Core::Lookup::LookupService, nil] the lookup service for object resolution @param address_type [String, nil] the default address type @param address_line_1 [String, nil] the default first address line @param address_line_2 [String, nil] the default second address line @param address_line_3 [String, nil] the default third address line @param address_line_4 [String, nil] the default fourth address line @param address_line_5 [String, nil] the default fifth address line @param post_code [String, nil] the default postal or zip code @param country [LUSI::API::Country::AddressCountry, nil] the default country @return [void]

# 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

Public Instance Methods

to_s(sep = nil) click to toggle source

Returns a string representation of the PersonAddress instance @return [String] the string representation of the PersonAddress instance

# 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