Class: Baldr::Envelope
Instance Attribute Summary
Attributes inherited from Segment
#children, #elements, #id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Segment
#[], #[]=, #add, #create, #fetch, helpers_for_elements, #method_missing, #number_of_segments, #sub_grammar, #sub_version
Constructor Details
#initialize(id = 'ISA') ⇒ Envelope
Returns a new instance of Envelope.
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/baldr/envelope.rb', line 26
def initialize(id = 'ISA')
super(id)
self.authorization_info_qualifier = '00'
self.authorization_info = ''
self.security_info_qualifier = '00'
self.security_info = ''
self.sender_id_qualifier = '00'
self.sender_id = ''
self.receiver_id_qualifier = '00'
self.receiver_id = ''
self.date_time = DateTime.now
self.standard_id = 'U'
self.standard_version_number = '00401'
self.acknowledgment_requested = '0'
self.usage_indicator = 'P'
self.component_separator = '>'
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Baldr::Segment
Class Method Details
.helpers ⇒ Object
22
23
24
|
# File 'lib/baldr/envelope.rb', line 22
def self.helpers
@helpers + [:receiver_id, :sender_id, :security_info, :authorization_info, :date_time]
end
|
Instance Method Details
#authorization_info ⇒ Object
70
71
72
|
# File 'lib/baldr/envelope.rb', line 70
def authorization_info
self['ISA02'].rstrip
end
|
#authorization_info=(value) ⇒ Object
74
75
76
|
# File 'lib/baldr/envelope.rb', line 74
def authorization_info=(value)
self['ISA02'] = value.to_s.ljust(record_def[1][:max])
end
|
#date_time ⇒ Object
102
103
104
|
# File 'lib/baldr/envelope.rb', line 102
def date_time
DateTime.parse "#{date} #{time}"
end
|
#date_time=(value) ⇒ Object
106
107
108
109
|
# File 'lib/baldr/envelope.rb', line 106
def date_time=(value)
self.date = value.strftime('%y%m%d')
self.time = value.strftime('%H%M')
end
|
#func_group_loop ⇒ Object
111
112
113
|
# File 'lib/baldr/envelope.rb', line 111
def func_group_loop
@func_group_loop ||= @children.select{ |c| c.id == 'GS' }.first
end
|
#GS(&block) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/baldr/envelope.rb', line 58
def GS(&block)
if @children.last && @children.last.id.to_s == 'GS'
loop = @children.last
loop.add_segment Baldr::FunctionalGroup.new
else
loop = Baldr::Loop.new('GS')
@children << loop
end
loop.current_segment.instance_eval &block if block_given?
end
|
#prepare! ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/baldr/envelope.rb', line 45
def prepare!
trailer = get_trailer('IEA')
trailer['IEA01'] = func_group_loop.segments.count.to_s
self.interchange_control_number ||= generate_control_number(9)
trailer['IEA02'] = interchange_control_number
end
|
#receiver_id ⇒ Object
94
95
96
|
# File 'lib/baldr/envelope.rb', line 94
def receiver_id
self['ISA08'].rstrip
end
|
#receiver_id=(value) ⇒ Object
98
99
100
|
# File 'lib/baldr/envelope.rb', line 98
def receiver_id=(value)
self['ISA08'] = value.to_s.ljust(record_def[7][:max])
end
|
#security_info ⇒ Object
78
79
80
|
# File 'lib/baldr/envelope.rb', line 78
def security_info
self['ISA04'].rstrip
end
|
#security_info=(value) ⇒ Object
82
83
84
|
# File 'lib/baldr/envelope.rb', line 82
def security_info=(value)
self['ISA04'] = value.to_s.ljust(record_def[3][:max])
end
|
#sender_id ⇒ Object
86
87
88
|
# File 'lib/baldr/envelope.rb', line 86
def sender_id
self['ISA06'].rstrip
end
|
#sender_id=(value) ⇒ Object
90
91
92
|
# File 'lib/baldr/envelope.rb', line 90
def sender_id=(value)
self['ISA06'] = value.to_s.ljust(record_def[5][:max])
end
|
#transactions ⇒ Object
54
55
56
|
# File 'lib/baldr/envelope.rb', line 54
def transactions
@transactions ||= func_group_loop.segments.map(&:transactions).flatten
end
|