Class: Marvin::AbstractParser

Inherits:
Object
  • Object
show all
Defined in:
lib/marvin/abstract_parser.rb

Overview

An abstract class for an IRC protocol Parser. Used as a basis for expirimentation.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ AbstractParser

Instantiates a parser instance, attempts to parse it for it’s command and it’s event.



14
15
16
17
18
# File 'lib/marvin/abstract_parser.rb', line 14

def initialize(line)
  self.line = line
  self.command = self.class.parse!(line)
  self.event = self.command.to_event unless self.command.blank?
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



10
11
12
# File 'lib/marvin/abstract_parser.rb', line 10

def command
  @command
end

#eventObject

Returns the value of attribute event.



10
11
12
# File 'lib/marvin/abstract_parser.rb', line 10

def event
  @event
end

#lineObject

Returns the value of attribute line.



10
11
12
# File 'lib/marvin/abstract_parser.rb', line 10

def line
  @line
end

Class Method Details

.parse(line) ⇒ Object



6
7
8
# File 'lib/marvin/abstract_parser.rb', line 6

def self.parse(line)
  return self.new(line.strip).to_event
end

Instance Method Details

#to_eventObject



20
21
22
# File 'lib/marvin/abstract_parser.rb', line 20

def to_event
  self.event
end