Sha256: 13d3617d312ea9c6cfee83c2a634c8559d2aeaa8bd3bcd30c6aebf924202a427

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

module Eancom
  module Edifact
    class LOC < Segment
      TAG = 'LOC'.freeze
      TYPE = :body.freeze

      attr_reader :segment_type

      def initialize(
        tag: nil,
        location_function_qualifier:,
        location_name_code: nil,
        first_related_name_code: nil,
        code_list_identification_code: nil,
        code_list_responsible_agency_code: nil
      )
        @tag = tag
        @location_function_qualifier = location_function_qualifier
        @location_name_code = location_name_code
        @first_related_name_code = first_related_name_code
        @code_list_identification_code = code_list_identification_code
        @code_list_responsible_agency_code = code_list_responsible_agency_code

        super(tag: tag || TAG)
      end

      def to_json_hash
        hash = {}
        hash.merge!(location_function_qualifier: find_identifier(:location_function_qualifier)) if @location_function_qualifier
        hash.merge!(location_name_code: @location_name_code) if @location_name_code
        hash.merge!(first_related_name_code: @first_related_name_code) if @first_related_name_code
        hash.merge!(code_list_identification_code: @code_list_identification_code) if @code_list_identification_code
        hash.merge!(code_list_responsible_agency_code: find_identifier(:code_list_responsible_agency_code)) if @code_list_responsible_agency_code
        hash
        outer_hash = {}
        outer_hash.merge!({ location: hash })
        outer_hash
      end

      def segment_type
        TYPE
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eancom-2.0.0 lib/eancom/edifact/segments/loc.rb