Sha256: 90b60811d51616bf1ecfc4724b7b90300e24461fb766db17b6d078ff02a7dcfa

Contents?: true

Size: 715 Bytes

Versions: 12

Compression:

Stored size: 715 Bytes

Contents

module Marvin
  # An abstract class for an IRC protocol
  # Parser. Used as a basis for expirimentation.
  class AbstractParser
    
    def self.parse(line)
      return self.new(line.strip).to_event
    end
    
    attr_accessor :line, :command, :event
    
    # Instantiates a parser instance, attempts to 
    # parse it for it's command and it's event.
    def initialize(line)
      self.line = line
      self.command = self.class.parse!(line)
      self.event = self.command.to_event unless self.command.blank?
    end
    
    def to_event
      self.event
    end
    
    private
    
    def self.parse!(line)
      raise NotImplementedError, "Must be implemented in a subclass"
    end
    
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
Sutto-marvin-0.1.20081120 lib/marvin/abstract_parser.rb
Sutto-marvin-0.2.0 lib/marvin/abstract_parser.rb
Sutto-marvin-0.2.1 lib/marvin/abstract_parser.rb
Sutto-marvin-0.2.2 lib/marvin/abstract_parser.rb
Sutto-marvin-0.2.3 lib/marvin/abstract_parser.rb
Sutto-marvin-0.2.4 lib/marvin/abstract_parser.rb
Sutto-marvin-0.3.0 lib/marvin/abstract_parser.rb
Sutto-marvin-0.3.2 lib/marvin/abstract_parser.rb
Sutto-marvin-0.3.3 lib/marvin/abstract_parser.rb
Sutto-marvin-0.3.4 lib/marvin/abstract_parser.rb
Sutto-marvin-0.4.0 lib/marvin/abstract_parser.rb
jeffrafter-marvin-0.1.20081120 lib/marvin/abstract_parser.rb