Class: Baldr::FunctionalGroup

Inherits:
Segment
  • Object
show all
Defined in:
lib/baldr/functional_group.rb

Instance Attribute Summary

Attributes inherited from Segment

#children, #elements, #id

Instance Method Summary collapse

Methods inherited from Segment

#[], #[]=, #add, #create, #fetch, helpers, helpers_for_elements, #method_missing, #number_of_segments, #sub_grammar

Constructor Details

#initialize(id = 'GS') ⇒ FunctionalGroup

Returns a new instance of FunctionalGroup.



14
15
16
17
18
19
20
21
22
# File 'lib/baldr/functional_group.rb', line 14

def initialize(id = 'GS')
  super(id)

  #self.application_senders_code = ''
  #self.application_receivers_code = ''
  self.date_time = DateTime.now
  self.responsible_agency_code = 'X'
  self.version_release_industry_code = '004010'
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Baldr::Segment

Instance Method Details

#date_timeObject



41
42
43
# File 'lib/baldr/functional_group.rb', line 41

def date_time
  DateTime.parse "#{date} #{time}"
end

#date_time=(value) ⇒ Object



45
46
47
48
# File 'lib/baldr/functional_group.rb', line 45

def date_time=(value)
  self.date = value.strftime('%Y%m%d')
  self.time = value.strftime('%H%M')
end

#prepare!Object



24
25
26
27
28
29
30
31
# File 'lib/baldr/functional_group.rb', line 24

def prepare!
  trailer = get_trailer('GE')

  trailer['GE01'] = transaction_loop.segments.count.to_s

  self.group_control_number ||= generate_control_number(9)
  trailer['GE02'] = group_control_number
end

#sub_version(grammar) ⇒ Object



33
34
35
# File 'lib/baldr/functional_group.rb', line 33

def sub_version(grammar)
  grammar.for_standard_version(version_release_industry_code)
end

#transaction_loopObject



50
51
52
# File 'lib/baldr/functional_group.rb', line 50

def transaction_loop
  @children.first
end

#transactionsObject



37
38
39
# File 'lib/baldr/functional_group.rb', line 37

def transactions
  transaction_loop.segments
end