class YAHL7::V2::Parser

The parser class is similar to the scanner class, except it returns the parsed HL7 messages rather than string representations of the HL7 messages (making it useful for pulling data out of these messages).

Attributes

scanner[R]
segment_sep[R]

Public Class Methods

new(src, segment_sep = YAHL7::V2::SEGMENT_SEP) click to toggle source
# File lib/yahl7/v2/parser.rb, line 17
def initialize(src, segment_sep = YAHL7::V2::SEGMENT_SEP)
  @scanner = Scanner.new(src)

  @segment_sep = segment_sep
end

Public Instance Methods

each() { |msg| ... } click to toggle source
# File lib/yahl7/v2/parser.rb, line 23
def each
  loop do
    msg = parse_next
    break if msg.nil?

    yield msg
  end
end
parse_next() click to toggle source
# File lib/yahl7/v2/parser.rb, line 32
def parse_next
  body = scanner.scan_next
  return nil if body.nil?

  Message.parse(body)
end