Class: CrawlerDetect::Detector

Inherits:
Object
  • Object
show all
Defined in:
lib/crawler_detect/detector.rb

Overview

since 0.1.0

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(user_agent) ⇒ CrawlerDetect::Detector

Returns instance of detector class.

Parameters:

  • user_agent (String)

    User-agent string to detect

Since:

  • 0.1.0



8
9
10
# File 'lib/crawler_detect/detector.rb', line 8

def initialize(user_agent)
  @user_agent = user_agent.to_s.dup
end

Instance Method Details

#crawler_nameString

Returns The detected crawler name from RAW data.

Returns:

  • (String)

    The detected crawler name from RAW data

Since:

  • 0.1.0



18
19
20
21
# File 'lib/crawler_detect/detector.rb', line 18

def crawler_name
  return unless is_crawler?
  @crawler_name
end

#is_crawler?true, false

Returns Is User-agent a crawler?.

Returns:

  • (true, false)

    Is User-agent a crawler?

Since:

  • 0.1.0



13
14
15
# File 'lib/crawler_detect/detector.rb', line 13

def is_crawler?
  @is_crawler ||= !completely_exclusion? && matches_crawler_list?
end