Class: BetterCap::Factories::Firewall

Inherits:
Object
  • Object
show all
Defined in:
lib/bettercap/factories/firewall.rb

Overview

Factory class responsible of creating the correct object for the current operating system of the user.

Constant Summary collapse

@@instance =
nil

Class Method Summary collapse

Class Method Details

.clearObject

Clear the instance of the BetterCap::Firewalls object.


37
38
39
# File 'lib/bettercap/factories/firewall.rb', line 37

def self.clear
  @@instance = nil
end

.getObject

Save and return an instance of the appropriate BetterCap::Firewalls object.


23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bettercap/factories/firewall.rb', line 23

def self.get
  return @@instance unless @@instance.nil?

  if RUBY_PLATFORM =~ /darwin/
    @@instance = Firewalls::OSX.new
  elsif RUBY_PLATFORM =~ /linux/
    @@instance = Firewalls::Linux.new
  else
    raise BetterCap::Error, 'Unsupported operating system'
  end

  @@instance
end