Class: PodIdent::Detector
- Inherits:
-
Object
- Object
- PodIdent::Detector
- Defined in:
- lib/pod_ident.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
Returns the value of attribute result.
-
#user_agent_string ⇒ Object
readonly
Returns the value of attribute user_agent_string.
Class Method Summary collapse
Instance Method Summary collapse
- #detect ⇒ Object
-
#initialize(user_agent_string) ⇒ Detector
constructor
A new instance of Detector.
Constructor Details
#initialize(user_agent_string) ⇒ Detector
18 19 20 |
# File 'lib/pod_ident.rb', line 18 def initialize(user_agent_string) @user_agent_string = user_agent_string end |
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
12 13 14 |
# File 'lib/pod_ident.rb', line 12 def result @result end |
#user_agent_string ⇒ Object (readonly)
Returns the value of attribute user_agent_string.
11 12 13 |
# File 'lib/pod_ident.rb', line 11 def user_agent_string @user_agent_string end |
Class Method Details
.bot? ⇒ Boolean
34 35 36 |
# File 'lib/pod_ident.rb', line 34 def self.bot? find_rule_bots || find_rule_custom_bots end |
.detect(user_agent_string) ⇒ Object
14 15 16 |
# File 'lib/pod_ident.rb', line 14 def self.detect(user_agent_string) new(user_agent_string).detect end |
Instance Method Details
#detect ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pod_ident.rb', line 22 def detect # !~ /[^[:space:]]/ is what Active Support does to detect blank strings return nil if user_agent_string !~ /[^[:space:]]/ rule = find_rule || find_rule_bots || find_rule_custom_bots self.result = DetectionResult.new(rule, user_agent_string) identify_platform if result.positive? result end |