Class: Marvin::AbstractParser
- Inherits:
-
Object
- Object
- Marvin::AbstractParser
- Defined in:
- lib/marvin/abstract_parser.rb
Overview
Abstract Class for implementing abstract parsers.
Direct Known Subclasses
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
-
.parse(line) ⇒ Marvin::IRC:Event
Parses a line and return the associated event.
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.
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
#command ⇒ Object
Returns the value of attribute command.
5 6 7 |
# File 'lib/marvin/abstract_parser.rb', line 5 def command @command end |
#event ⇒ Object
Returns the value of attribute event.
5 6 7 |
# File 'lib/marvin/abstract_parser.rb', line 5 def event @event end |
#line ⇒ Object
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.
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_event ⇒ Object
15 16 17 |
# File 'lib/marvin/abstract_parser.rb', line 15 def to_event @event end |