Class: Eancom::Edifact::MEA

Inherits:
Segment
  • Object
show all
Defined in:
lib/eancom/edifact/segments/mea.rb

Constant Summary collapse

TAG =
'MEA'.freeze
TYPE =
:body.freeze

Instance Attribute Summary collapse

Attributes inherited from Segment

#tag

Instance Method Summary collapse

Methods inherited from Segment

#array, initialize_by_components, #is_body?, #is_footer?, #is_header?, #item_group_name, #starts_item?, #starts_location?, #starts_message?, #structure, #tag?, #to_edi, #to_hash, #to_s, #validate_structure

Constructor Details

#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) ⇒ MEA

Returns a new instance of MEA.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/eancom/edifact/segments/mea.rb', line 9

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

Instance Attribute Details

#segment_typeObject (readonly)

Returns the value of attribute segment_type.



7
8
9
# File 'lib/eancom/edifact/segments/mea.rb', line 7

def segment_type
  @segment_type
end

Instance Method Details

#group_nameObject



43
44
45
# File 'lib/eancom/edifact/segments/mea.rb', line 43

def group_name
  'characterisitcs'
end

#to_json_hashObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/eancom/edifact/segments/mea.rb', line 32

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!(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