Class: Eancom::Edifact::CUX

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Attributes inherited from Segment

#tag

Instance Method Summary collapse

Methods inherited from Segment

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

Constructor Details

#initialize(tag: nil, currency_usage_code_qualifier_1:, currency_identification_code_1:, currency_type_code_qualifier_1: nil, currency_rate_value_1: nil, currency_usage_code_qualifier_2: nil, currency_identification_code_2: nil, currency_type_code_qualifier_2: nil, currency_rate_value_2: nil, currency_exchange_rate: nil, exchange_rate_currency_market_identifier: nil) ⇒ CUX

Returns a new instance of CUX.



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

def initialize(
  tag: nil,
  currency_usage_code_qualifier_1:,
  currency_identification_code_1:,
  currency_type_code_qualifier_1: nil,
  currency_rate_value_1: nil,
  currency_usage_code_qualifier_2: nil,
  currency_identification_code_2: nil,
  currency_type_code_qualifier_2: nil,
  currency_rate_value_2: nil,
  currency_exchange_rate: nil,
  exchange_rate_currency_market_identifier: nil
)
  @tag = tag
  @currency_usage_code_qualifier_1 = currency_usage_code_qualifier_1
  @currency_identification_code_1 = currency_identification_code_1
  @currency_type_code_qualifier_1 = currency_type_code_qualifier_1
  @currency_rate_value_1 = currency_rate_value_1
  @currency_usage_code_qualifier_2 = currency_usage_code_qualifier_2
  @currency_identification_code_2 = currency_identification_code_2
  @currency_type_code_qualifier_2 = currency_type_code_qualifier_2
  @currency_rate_value_2 = currency_rate_value_2
  @currency_exchange_rate = currency_exchange_rate
  @exchange_rate_currency_market_identifier = exchange_rate_currency_market_identifier

  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/cux.rb', line 7

def segment_type
  @segment_type
end

Instance Method Details

#item_group_nameObject



50
51
52
# File 'lib/eancom/edifact/segments/cux.rb', line 50

def item_group_name
  'prices'
end

#to_json_hashObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/eancom/edifact/segments/cux.rb', line 37

def to_json_hash
  hash = {}
  hash.merge!(currency_usage_code_qualifier_1: find_identifier(:currency_usage_code_qualifier_1)) if @currency_usage_code_qualifier_1
  hash.merge!(currency_identification_code_1: @currency_identification_code_1) if @currency_identification_code_1
  hash.merge!(currency_type_code_qualifier_1: find_identifier(:currency_type_code_qualifier_1)) if @currency_type_code_qualifier_1
  hash.merge!(currency_rate_value_1: @currency_rate_value_1) if @currency_rate_value_1
  hash.merge!(currency_usage_code_qualifier_2: find_identifier(:currency_usage_code_qualifier_2)) if @currency_usage_code_qualifier_2
  hash.merge!(currency_identification_code_2: @currency_identification_code_2) if @currency_identification_code_2
  hash.merge!(currency_type_code_qualifier_2: find_identifier(:currency_type_code_qualifier_2)) if @currency_type_code_qualifier_2
  hash.merge!(currency_rate_value_2: @currency_rate_value_2) if @currency_rate_value_2
  { currency: hash }
end