Sha256: d394eec8f96f9eeb4fe308f8f0f73e28945fac248d32a14a2c4b607806e1442d

Contents?: true

Size: 710 Bytes

Versions: 40

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

require_relative 'config/resolver'
require_relative 'validators/domains'
require_relative 'validators/ip_ranges'

module Legitbot
  ##
  # Represents a bot instance match. Typical methods are
  # +valid?+, +fake?+ and +detected_as+
  #
  class BotMatch
    include Legitbot::Validators::IpRanges
    include Legitbot::Validators::Domains

    def initialize(ip)
      @ip = ip
    end

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

    def valid?
      valid_ip? && valid_domain?
    end

    def fake?
      !valid?
    end

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

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

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
legitbot-1.11.2 lib/legitbot/botmatch.rb
legitbot-1.11.1 lib/legitbot/botmatch.rb
legitbot-1.11.0 lib/legitbot/botmatch.rb
legitbot-1.10.6 lib/legitbot/botmatch.rb
legitbot-1.10.5 lib/legitbot/botmatch.rb
legitbot-1.10.4 lib/legitbot/botmatch.rb
legitbot-1.10.3 lib/legitbot/botmatch.rb
legitbot-1.10.1 lib/legitbot/botmatch.rb
legitbot-1.10.0 lib/legitbot/botmatch.rb
legitbot-1.9.4 lib/legitbot/botmatch.rb
legitbot-1.9.3 lib/legitbot/botmatch.rb
legitbot-1.9.2 lib/legitbot/botmatch.rb
legitbot-1.9.1 lib/legitbot/botmatch.rb
legitbot-1.9.0 lib/legitbot/botmatch.rb
legitbot-1.8.0 lib/legitbot/botmatch.rb
legitbot-1.7.3 lib/legitbot/botmatch.rb
legitbot-1.7.2 lib/legitbot/botmatch.rb
legitbot-1.7.1 lib/legitbot/botmatch.rb
legitbot-1.7.0 lib/legitbot/botmatch.rb
legitbot-1.6.1 lib/legitbot/botmatch.rb