Module: Wifimap::ParserFactory

Defined in:
lib/wifimap/parser_factory.rb

Overview

Instantiate the correct parser class according to the dump format.

Class Method Summary collapse

Class Method Details

.create(file_content) ⇒ Object

Instantiate the parser factory or raise an error if the dump is not supported.



9
10
11
12
13
14
15
16
17
18
# File 'lib/wifimap/parser_factory.rb', line 9

def create(file_content)
  case dump_format(file_content)
  when :airodump
    Wifimap::Parser::Airodump.new(file_content)
  when :sniff_probes
    Wifimap::Parser::SniffProbes.new(file_content)
  else
    raise Error, 'Unsupported dump format'
  end
end

.dump_format(file_content) ⇒ Symbol|Nil

Check the file content and identify the correct dump format.

Parameters:

  • file_content (String)

Returns:

  • (Symbol|Nil)


24
25
26
27
# File 'lib/wifimap/parser_factory.rb', line 24

def dump_format(file_content)
  return :airodump if airodump_format?(file_content)
  return :sniff_probes if sniff_probes_format?(file_content)
end