Class: Hbci::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/hbci/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(raw_response) ⇒ Response

Returns a new instance of Response.



5
6
7
8
# File 'lib/hbci/response.rb', line 5

def initialize(raw_response)
  @raw_response = raw_response
  @raw_segments = Parser.parse(raw_response.force_encoding('iso-8859-1'))
end

Instance Method Details

#find(segment_type) ⇒ Object



10
11
12
13
14
# File 'lib/hbci/response.rb', line 10

def find(segment_type)
  segments = find_all(segment_type)
  warn "more then one #{segment_type} segment available" if segments.size > 1
  segments.first
end

#find_all(segment_type) ⇒ Object



16
17
18
# File 'lib/hbci/response.rb', line 16

def find_all(segment_type)
  @raw_segments.select { |sd| sd[0][0] == segment_type }.map { |sd| Hbci::SegmentFactory.build(sd) }
end

#to_sObject



20
21
22
# File 'lib/hbci/response.rb', line 20

def to_s
  @raw_response
end