Class: RBEDI::FunctionalGroup

Inherits:
Object
  • Object
show all
Includes:
Codes
Defined in:
lib/rbedi/functional_group.rb

Constant Summary

Constants included from Codes

Codes::ELEMENT_SEPARATOR, Codes::INTERCHANGE_CONTROL_VERSION_NUMBER, Codes::SEGMENT_TERMINATOR, Codes::VERSION_CODE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group_control_number:, functional_identifier_code:, application_sender_code:, application_receiver_code:, date_time: DateTime.now, transaction_sets: []) ⇒ FunctionalGroup

Returns a new instance of FunctionalGroup.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rbedi/functional_group.rb', line 5

def initialize(
  group_control_number:,
  functional_identifier_code:,
  application_sender_code:,
  application_receiver_code:,
  date_time: DateTime.now,
  transaction_sets: []
)
  @group_control_number = group_control_number.to_s
  @functional_identifier_code = functional_identifier_code
  @application_sender_code = application_sender_code
  @application_receiver_code = application_receiver_code
  @transaction_sets = transaction_sets
  @date_time = EDIDateTime.new(date_time)
end

Instance Attribute Details

#application_receiver_codeObject

Returns the value of attribute application_receiver_code.



49
50
51
# File 'lib/rbedi/functional_group.rb', line 49

def application_receiver_code
  @application_receiver_code
end

#application_sender_codeObject

Returns the value of attribute application_sender_code.



49
50
51
# File 'lib/rbedi/functional_group.rb', line 49

def application_sender_code
  @application_sender_code
end

#date_timeObject

Returns the value of attribute date_time.



49
50
51
# File 'lib/rbedi/functional_group.rb', line 49

def date_time
  @date_time
end

#functional_identifier_codeObject

Returns the value of attribute functional_identifier_code.



49
50
51
# File 'lib/rbedi/functional_group.rb', line 49

def functional_identifier_code
  @functional_identifier_code
end

#group_control_numberObject

Returns the value of attribute group_control_number.



49
50
51
# File 'lib/rbedi/functional_group.rb', line 49

def group_control_number
  @group_control_number
end

#transaction_setsObject

Returns the value of attribute transaction_sets.



49
50
51
# File 'lib/rbedi/functional_group.rb', line 49

def transaction_sets
  @transaction_sets
end

Instance Method Details

#headerObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rbedi/functional_group.rb', line 27

def header
  Segment.new(
    :functional_group_header,
    functional_identifier_code: @functional_identifier_code,
    application_sender_code: @application_sender_code,
    application_receiver_code: @application_receiver_code,
    date: @date_time.ccyymmdd,
    time: @date_time.hhmm,
    group_control_number: @group_control_number,
    responsible_agency_code: :accredited_standards_committee_x12,
    version_code: Codes::VERSION_CODE
  )
end

#to_sObject



21
22
23
24
25
# File 'lib/rbedi/functional_group.rb', line 21

def to_s
  header.to_s +
    @transaction_sets.map(&:to_s).join +
    trailer.to_s
end

#trailerObject



41
42
43
44
45
46
47
# File 'lib/rbedi/functional_group.rb', line 41

def trailer
  Segment.new(
    :functional_group_trailer,
    transaction_set_count: @transaction_sets.length,
    group_control_number: @group_control_number
  )
end