Sha256: 50cf2e28e5a7992f342cab5134e0ff596663e816bd09fa079140e68a9f00a11d
Contents?: true
Size: 559 Bytes
Versions: 2
Compression:
Stored size: 559 Bytes
Contents
require 'ostruct' class StatefulParser include DynamicParser::MicroParser::Stateful def initialize @data = [] end def detect(txt) self.class.detect(txt) end def self.detect(txt) if txt.match('stateful') == nil false else true end end def parse!(txt) tokens = [] txt.split(' ').each_with_index do |piece, i| @data.push OpenStruct.new(index: i, content: piece) end # you could be doing some IO here, like writing to a file, database, http... end def gimme_data @data end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dynamic_parser-0.0.2 | spec/support/stateful_parser.rb |
dynamic_parser-0.0.0.pre.5 | spec/support/stateful_parser.rb |