Sha256: 86d11f68dbc198ba0b3bc6315cfd34b1d90480c811b6c6285dac2d311c58c941
Contents?: true
Size: 465 Bytes
Versions: 2
Compression:
Stored size: 465 Bytes
Contents
require 'netutils/fsm' class Parser < FSM def initialize super @regexp = Array.new end def add(sname, cb, regexp = nil) super(sname, cb) @regexp.push(regexp) end def regexp r = @regexp[@state] r = /^.*$/ if r == nil return r end def parse(buf) buf.each_line do |l| unless l.chomp! =~ regexp raise(ArgumentError, "No match at #{state_name}: \"#{l}\" " + "to #{regexp.to_s}") end send(cb, l, $~) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
netutils-0.1.2 | lib/netutils/parser.rb |
netutils-0.1.1 | lib/netutils/parser.rb |