Class: Baldr::Transaction

Inherits:
Segment
  • Object
show all
Defined in:
lib/baldr/transaction.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_version

Constructor Details

#initialize(id = 'ST') ⇒ Transaction

Returns a new instance of Transaction.



8
9
10
# File 'lib/baldr/transaction.rb', line 8

def initialize(id = 'ST')
  super(id)
end

Dynamic Method Handling

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

Instance Method Details

#functional_group(version) ⇒ Object



25
26
27
# File 'lib/baldr/transaction.rb', line 25

def functional_group(version)
  version.for_transaction_set(transaction_set_code)::FUNCTIONAL_GROUP
end

#prepare!Object



12
13
14
15
16
17
18
19
# File 'lib/baldr/transaction.rb', line 12

def prepare!
  trailer = get_trailer('SE')

  trailer['SE01'] = number_of_segments.to_s

  self.transaction_control_number ||= generate_control_number(9)
  trailer['SE02'] = transaction_control_number
end

#sub_grammar(version) ⇒ Object



21
22
23
# File 'lib/baldr/transaction.rb', line 21

def sub_grammar(version)
  version.for_transaction_set(transaction_set_code)
end