Class: Fusuma::Plugin::Parsers::Parser

Inherits:
Base
  • Object
show all
Defined in:
lib/fusuma/plugin/parsers/parser.rb

Overview

Parser change record and tag in event Inherite this base class

Direct Known Subclasses

LibinputGestureParser

Instance Method Summary collapse

Methods inherited from Base

#config_index, #config_param_types, #config_params, inherited, plugins

Methods included from CustomProcess

#fork

Instance Method Details

#parse(event) ⇒ Event

Parse Event and convert Record and Tag if ‘#parse_record` return nil, this method will return original event

Parameters:

  • event (Event)

Returns:

  • (Event)


15
16
17
18
19
20
21
22
23
24
# File 'lib/fusuma/plugin/parsers/parser.rb', line 15

def parse(event)
  return event if event.tag != source

  new_record = parse_record(event.record)
  return event if new_record.nil?

  event.record = new_record
  event.tag = tag
  event
end

#parse_record(_record) ⇒ Record?

parse Record object

Parameters:

  • _record (Record)

Returns:

  • (Record, nil)


39
40
41
# File 'lib/fusuma/plugin/parsers/parser.rb', line 39

def parse_record(_record)
  nil
end

#sourceObject

Set source for tag from config.yml. DEFAULT_SOURCE is defined in each Parser plugins.



28
29
30
# File 'lib/fusuma/plugin/parsers/parser.rb', line 28

def source
  @source ||= config_params(:source) || self.class.const_get('DEFAULT_SOURCE')
end

#tagObject



32
33
34
# File 'lib/fusuma/plugin/parsers/parser.rb', line 32

def tag
  @tag ||= self.class.name.split('::').last.underscore
end