Class: Netgrep::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/netgrep/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log_file:, netblocks_file:, num_workers: 1, ignore_ipv6: false) ⇒ Runner

Returns a new instance of Runner.



8
9
10
11
12
13
14
15
16
# File 'lib/netgrep/runner.rb', line 8

def initialize(log_file:, netblocks_file:, num_workers: 1, ignore_ipv6: false)
  @log_file = log_file
  @netblocks_file = netblocks_file
  @num_workers = num_workers
  @ignore_ipv6 = ignore_ipv6?(ignore_ipv6)
  @matches = []
  @worker_pids = []
  @pipe_reader, @pipe_writer = IO.pipe
end

Instance Attribute Details

#matchesObject

Returns the value of attribute matches.



6
7
8
# File 'lib/netgrep/runner.rb', line 6

def matches
  @matches
end

Instance Method Details

#runObject



18
19
20
21
22
23
24
# File 'lib/netgrep/runner.rb', line 18

def run
  start_workers
  collect_matches
  shutdown_workers
  print_matches
  self
end