class Eancom::Edifact::NAD

Constants

TAG
TYPE

Public Class Methods

new( tag: nil, party_function_code_qualifier:, party_identifier:, code_list_identification_code_1: '', code_list_responsible_agency_code_1: nil, name_and_address_description_1: nil, name_and_address_description_2: nil, name_and_address_description_3: nil, name_and_address_description_4: nil, name_and_address_description_5: nil, party_name_1: nil, party_name_2: nil, party_name_3: nil, party_name_4: nil, party_name_5: nil, street_and_number_1: nil, street_and_number_2: nil, street_and_number_3: nil, street_and_number_4: nil, street_and_number_5: nil, city_name: nil, country_sub_entity_name_code: nil, code_list_identification_code_2: nil, code_list_responsible_agency_code_2: nil, country_sub_entry_name: nil, postal_identification_code: nil, country_name_code: nil ) click to toggle source
Calls superclass method Eancom::Edifact::Segment::new
# File lib/eancom/edifact/segments/nad.rb, line 7
def initialize(
  tag: nil,
  party_function_code_qualifier:,
  party_identifier:,
  code_list_identification_code_1: '',
  code_list_responsible_agency_code_1: nil,
  name_and_address_description_1: nil,
  name_and_address_description_2: nil,
  name_and_address_description_3: nil,
  name_and_address_description_4: nil,
  name_and_address_description_5: nil,
  party_name_1: nil,
  party_name_2: nil,
  party_name_3: nil,
  party_name_4: nil,
  party_name_5: nil,
  street_and_number_1: nil,
  street_and_number_2: nil,
  street_and_number_3: nil,
  street_and_number_4: nil,
  street_and_number_5: nil,
  city_name: nil,
  country_sub_entity_name_code: nil,
  code_list_identification_code_2: nil,
  code_list_responsible_agency_code_2: nil,
  country_sub_entry_name: nil,
  postal_identification_code: nil,
  country_name_code: nil
)
  @tag = tag
  @party_function_code_qualifier = party_function_code_qualifier
  @party_identifier = party_identifier
  @code_list_identification_code_1 = code_list_identification_code_1
  @code_list_responsible_agency_code_1 = code_list_responsible_agency_code_1
  @name_and_address_description_1 = name_and_address_description_1
  @name_and_address_description_2 = name_and_address_description_2
  @name_and_address_description_3 = name_and_address_description_3
  @name_and_address_description_4 = name_and_address_description_4
  @name_and_address_description_5 = name_and_address_description_5
  @party_name_1 = party_name_1
  @party_name_2 = party_name_2
  @party_name_3 = party_name_3
  @party_name_4 = party_name_4
  @party_name_5 = party_name_5
  @street_and_number_1 = street_and_number_1
  @street_and_number_2 = street_and_number_2
  @street_and_number_3 = street_and_number_3
  @street_and_number_4 = street_and_number_4
  @street_and_number_5 = street_and_number_5
  @city_name = city_name
  @country_sub_entity_name_code = country_sub_entity_name_code
  @code_list_responsible_agency_code_2 = code_list_identification_code_2
  @code_list_responsible_agency_code_2 = code_list_responsible_agency_code_2
  @country_sub_entry_name = country_sub_entry_name
  @postal_identification_code = postal_identification_code
  @country_name_code = country_name_code
  super(tag: tag || TAG)
end

Public Instance Methods

group_name() click to toggle source
# File lib/eancom/edifact/segments/nad.rb, line 100
def group_name
  'nads'
end
segment_type() click to toggle source
# File lib/eancom/edifact/segments/nad.rb, line 96
def segment_type
  TYPE
end
to_json_hash() click to toggle source
# File lib/eancom/edifact/segments/nad.rb, line 66
def to_json_hash
  hash = { identifier => {} }
  hash[identifier].merge!({ party_identifier: @party_identifier }) if @party_identifier
  hash[identifier].merge!({ name_and_address_description_1: @name_and_address_description_1 }) if @name_and_address_description_1
  hash[identifier].merge!({ name_and_address_description_2: @name_and_address_description_2 }) if @name_and_address_description_2
  hash[identifier].merge!({ name_and_address_description_3: @name_and_address_description_3 }) if @name_and_address_description_3
  hash[identifier].merge!({ name_and_address_description_4: @name_and_address_description_4 }) if @name_and_address_description_4
  hash[identifier].merge!({ name_and_address_description_5: @name_and_address_description_5 }) if @name_and_address_description_5
  hash[identifier].merge!({ party_name_1: @party_name_1 }) if @party_name_1
  hash[identifier].merge!({ party_name_2: @party_name_2 }) if @party_name_2
  hash[identifier].merge!({ party_name_3: @party_name_3 }) if @party_name_3
  hash[identifier].merge!({ party_name_4: @party_name_4 }) if @party_name_4
  hash[identifier].merge!({ party_name_5: @party_name_5 }) if @party_name_5
  hash[identifier].merge!({ street_and_number_1: @street_and_number_1 }) if @street_and_number_1
  hash[identifier].merge!({ street_and_number_2: @street_and_number_2 }) if @street_and_number_2
  hash[identifier].merge!({ street_and_number_3: @street_and_number_3 }) if @street_and_number_3
  hash[identifier].merge!({ street_and_number_4: @street_and_number_4 }) if @street_and_number_4
  hash[identifier].merge!({ street_and_number_5: @street_and_number_5 }) if @street_and_number_5
  hash[identifier].merge!({ city_name: @city_name }) if @city_name
  hash[identifier].merge!({ country_sub_entity_name_code: @country_sub_entity_name_code }) if @country_sub_entity_name_code
  hash[identifier].merge!({ country_sub_entry_name: @country_sub_entry_name }) if @country_sub_entry_name
  hash[identifier].merge!({ postal_identification_code: @postal_identification_code }) if @postal_identification_code
  hash[identifier].merge!({ country_name_code: @country_name_code }) if @country_name_code

  hash.merge!({ identifier: @identifier }) if @identifier
  hash = {} if hash[identifier].empty?
  hash

end

Private Instance Methods

identifier() click to toggle source
# File lib/eancom/edifact/segments/nad.rb, line 106
def identifier
  @identifier ||= structure.find(:party_function_code_qualifier).dictionary[@party_function_code_qualifier][:identifier]
end