Class: Marvin::AbstractParser

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

Overview

Abstract Class for implementing abstract parsers.

Direct Known Subclasses

Parsers::RagelParser, Parsers::SimpleParser

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.



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

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

Instance Attribute Details

#commandObject

Returns the value of attribute command.



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

def command
  @command
end

#eventObject

Returns the value of attribute event.



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

def event
  @event
end

#lineObject

Returns the value of attribute line.



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

def line
  @line
end

Class Method Details

.parse(line) ⇒ Marvin::IRC:Event

Parses a line and return the associated event.

Returns:

  • (Marvin::IRC:Event)

    the parsed event



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

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

Instance Method Details

#to_eventObject



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

def to_event
  @event
end