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.



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

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



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

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



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

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

#to_sObject



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

def to_s
  @raw_response
end