Sha256: a60733ad318c6ddbe26446b0ba9acf38eef955b9d79ac74c080eef61ea479a36

Contents?: true

Size: 595 Bytes

Versions: 6

Compression:

Stored size: 595 Bytes

Contents

module Marvin
  class AbstractParser
    
    attr_accessor :line, :command, :event
    
    # Instantiates a parser instance, attempts to 
    # parse it for it's command and it's event.
    def initialize(line)
      @line    = line
      @command = self.class.parse!(line)
      @event   = @command.to_event unless @command.blank?
    end
    
    def to_event
      @event
    end
    
    def self.parse(line)
      new(line.strip).to_event
    end
    
    protected
    
    def self.parse!(line)
      raise NotImplementedError, "Must be implemented in a subclass"
    end
    
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
Sutto-marvin-0.8.0.0 lib/marvin/abstract_parser.rb
Sutto-marvin-0.8.0.1 lib/marvin/abstract_parser.rb
marvin-0.8.1 lib/marvin/abstract_parser.rb
marvin-0.8.0.2 lib/marvin/abstract_parser.rb
marvin-0.8.0.1 lib/marvin/abstract_parser.rb
marvin-0.8.0.0 lib/marvin/abstract_parser.rb