Class: Marvin::AbstractParser
- Inherits:
-
Object
- Object
- Marvin::AbstractParser
- Defined in:
- lib/marvin/abstract_parser.rb
Overview
An abstract class for an IRC protocol Parser. Used as a basis for expirimentation.
Direct Known Subclasses
Parsers::RagelParser, Parsers::RegexpParser, Parsers::SimpleParser
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#event ⇒ Object
Returns the value of attribute event.
-
#line ⇒ Object
Returns the value of attribute line.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(line) ⇒ AbstractParser
constructor
Instantiates a parser instance, attempts to parse it for it’s command and it’s event.
- #to_event ⇒ Object
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
#command ⇒ Object
Returns the value of attribute command.
10 11 12 |
# File 'lib/marvin/abstract_parser.rb', line 10 def command @command end |
#event ⇒ Object
Returns the value of attribute event.
10 11 12 |
# File 'lib/marvin/abstract_parser.rb', line 10 def event @event end |
#line ⇒ Object
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_event ⇒ Object
20 21 22 |
# File 'lib/marvin/abstract_parser.rb', line 20 def to_event self.event end |