Module: Detector

Defined in:
lib/detectors/detector.rb

Overview

Wraps around different detector implementations

Class Method Summary collapse

Class Method Details

.ifconfig(params) ⇒ Object



10
11
12
13
14
# File 'lib/detectors/detector.rb', line 10

def self.ifconfig(params)
  return unless params[:type] == 'ifconfig' && params[:version] == 6

  Ifconfig.new(params[:network_interface], params[:version])
end

.ipify(params) ⇒ Object



16
17
18
19
# File 'lib/detectors/detector.rb', line 16

def self.ipify(params)
  return unless params[:type] == 'ipify'
  Ipify.new(params[:network_interface], params[:version])
end

.ruby_sockets(params) ⇒ Object



21
22
23
# File 'lib/detectors/detector.rb', line 21

def self.ruby_sockets(params)
  Ruby.new(params[:version]) if params[:type] == 'ruby'
end

.setup(params) ⇒ Object



3
4
5
6
7
8
# File 'lib/detectors/detector.rb', line 3

def self.setup(params)
  ifconfig(params) ||
    ipify(params) ||
    ruby_sockets(params) ||
    timestamp(params)
end

.timestamp(params) ⇒ Object



25
26
27
# File 'lib/detectors/detector.rb', line 25

def self.timestamp(params)
  Timestamp.new if params[:type] == 'timestamp'
end