Class: Legitbot::BotMatch

Inherits:
Object
  • Object
show all
Includes:
Validators::Domains, Validators::IpRanges
Defined in:
lib/legitbot/botmatch.rb

Overview

Represents a bot instance match. Typical methods are valid?, fake? and detected_as

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Validators::Domains

included, #valid_domain?

Methods included from Validators::IpRanges

included, #valid_ip?

Constructor Details

#initialize(ip) ⇒ BotMatch

Returns a new instance of BotMatch.



16
17
18
# File 'lib/legitbot/botmatch.rb', line 16

def initialize(ip)
  @ip = ip
end

Class Method Details

.fake?(ip) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/legitbot/botmatch.rb', line 36

def self.fake?(ip)
  new(ip).fake?
end

.valid?(ip) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/legitbot/botmatch.rb', line 32

def self.valid?(ip)
  new(ip).valid?
end

Instance Method Details

#detected_asObject



20
21
22
# File 'lib/legitbot/botmatch.rb', line 20

def detected_as
  self.class.name.split('::').last.downcase.to_sym
end

#fake?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/legitbot/botmatch.rb', line 28

def fake?
  !valid?
end

#valid?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/legitbot/botmatch.rb', line 24

def valid?
  valid_ip? && valid_domain?
end