Class: Hbci::Message
- Inherits:
-
Object
- Object
- Hbci::Message
- Defined in:
- lib/hbci/message.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#connector ⇒ Object
readonly
Returns the value of attribute connector.
-
#dialog ⇒ Object
readonly
Returns the value of attribute dialog.
-
#next_position ⇒ Object
Returns the value of attribute next_position.
-
#sec_ref ⇒ Object
readonly
Returns the value of attribute sec_ref.
-
#segments ⇒ Object
readonly
Returns the value of attribute segments.
Instance Method Summary collapse
- #add_segment(segment) ⇒ Object
- #compile ⇒ Object
-
#initialize(connector, dialog = nil) ⇒ Message
constructor
A new instance of Message.
- #to_base64 ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(connector, dialog = nil) ⇒ Message
Returns a new instance of Message.
8 9 10 11 12 13 14 |
# File 'lib/hbci/message.rb', line 8 def initialize(connector, dialog = nil) @connector = connector @dialog = dialog @sec_ref = generate_security_reference @segments = [] @next_position = 1 end |
Instance Attribute Details
#connector ⇒ Object (readonly)
Returns the value of attribute connector.
5 6 7 |
# File 'lib/hbci/message.rb', line 5 def connector @connector end |
#dialog ⇒ Object (readonly)
Returns the value of attribute dialog.
5 6 7 |
# File 'lib/hbci/message.rb', line 5 def dialog @dialog end |
#next_position ⇒ Object
Returns the value of attribute next_position.
6 7 8 |
# File 'lib/hbci/message.rb', line 6 def next_position @next_position end |
#sec_ref ⇒ Object (readonly)
Returns the value of attribute sec_ref.
5 6 7 |
# File 'lib/hbci/message.rb', line 5 def sec_ref @sec_ref end |
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
5 6 7 |
# File 'lib/hbci/message.rb', line 5 def segments @segments end |
Instance Method Details
#add_segment(segment) ⇒ Object
16 17 18 19 |
# File 'lib/hbci/message.rb', line 16 def add_segment(segment) segment.build(self) @segments.push(segment) end |
#compile ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hbci/message.rb', line 21 def compile @segments.each_with_index do |segment, _index| segment.compile unless segment.head.position segment.head.position = @next_position @next_position += 1 end end @segments.each do |segment| segment.after_compile if segment.respond_to?(:after_compile) end end |
#to_base64 ⇒ Object
38 39 40 |
# File 'lib/hbci/message.rb', line 38 def to_base64 Base64.encode64(to_s) end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/hbci/message.rb', line 34 def to_s segments.join('') end |