Sha256: 9498c618ddd5131e21556105443bd98c4fc651dd07ad332e938b0c5d17217787

Contents?: true

Size: 1.33 KB

Versions: 12

Compression:

Stored size: 1.33 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:,
        code_list_identification_code: nil,
        code_list_responsible_agancy_code: nil
      )
        @tag = tag
        @location_function_qualifier = location_function_qualifier
        @location_name_code = location_name_code
        @code_list_identification_code = code_list_identification_code
        @code_list_responsible_agancy_code = code_list_responsible_agancy_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!(code_list_identification_code: @code_list_identification_code) if @code_list_identification_code
        hash.merge!(code_list_responsible_agancy_code: find_identifier(:code_list_responsible_agancy_code)) if @code_list_responsible_agancy_code
        hash
        outer_hash = {}
        outer_hash.merge!({ location: hash})
        outer_hash
      end

      def segment_type
        TYPE
      end

    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
eancom-1.5.7 lib/eancom/edifact/segments/loc.rb
eancom-1.5.6 lib/eancom/edifact/segments/loc.rb
eancom-1.5.5 lib/eancom/edifact/segments/loc.rb
eancom-1.5.4 lib/eancom/edifact/segments/loc.rb
eancom-1.5.2 lib/eancom/edifact/segments/loc.rb
eancom-1.5.1 lib/eancom/edifact/segments/loc.rb
eancom-1.5.0 lib/eancom/edifact/segments/loc.rb
eancom-1.4.0 lib/eancom/edifact/segments/loc.rb
eancom-1.3.0 lib/eancom/edifact/segments/loc.rb
eancom-1.2.0 lib/eancom/edifact/segments/loc.rb
eancom-1.1.1 lib/eancom/edifact/segments/loc.rb
eancom-1.1.0 lib/eancom/edifact/segments/loc.rb