Sha256: 84be451cf3dd5d1376ce0e5d9a14040f6cb1584421d5a2c14ef3468860e4295b

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

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

      attr_reader :segment_type

      def initialize(
        tag: nil,
        measurement_purpose_code_qualifier:,
        measured_attribute_code:,
        measurement_significance_code: nil,
        measurment_unit_code:,
        measurement_value:,
        range_minimum_value: nil,
        range_maximum_value: nil
      )
        @tag = tag

        @measurement_purpose_code_qualifier = measurement_purpose_code_qualifier
        @measured_attribute_code = measured_attribute_code
        @measurement_significance_code = measurement_significance_code
        @measurment_unit_code = measurment_unit_code
        @measurement_value = measurement_value
        @range_minimum_value = range_minimum_value
        @range_maximum_value = range_maximum_value

        super(tag: tag || TAG)
      end

      def to_json_hash
        hash = {}
        hash.merge!(measurement_purpose_code_qualifier: find_identifier(:measurement_purpose_code_qualifier)) if @measurement_purpose_code_qualifier
        hash.merge!(measured_attribute_code: find_identifier(:measured_attribute_code)) if @measured_attribute_code
        hash.merge!(measurement_significance_code: find_identifier(:measurement_significance_code)) if @measurement_significance_code
        hash.merge!(measurment_unit_code: find_identifier(:measurment_unit_code)) if @measurment_unit_code
        hash.merge!(measurement_value: @measurement_value) if @measurement_value
        hash.merge!(range_minimum_value: @range_minimum_value) if @range_minimum_value
        hash.merge!(range_maximum_value: @range_maximum_value) if @range_maximum_value
        hash
      end

      def group_name
        'characterisitcs'
      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/mea.rb