Class: Marvin::AbstractParser

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

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.



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

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.



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

def command
  @command
end

#eventObject

Returns the value of attribute event.



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

def event
  @event
end

#lineObject

Returns the value of attribute line.



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

def line
  @line
end

Class Method Details

.parse(line) ⇒ Object



18
19
20
# File 'lib/marvin/abstract_parser.rb', line 18

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

Instance Method Details

#to_eventObject



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

def to_event
  @event
end