Module: NginxTail::HttpUserAgent
- Defined in:
- lib/ntail/http_user_agent.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
:nodoc:
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/ntail/http_user_agent.rb', line 87 def self.included(base) # :nodoc: base.class_eval do def self.search_bot?(http_user_agent) SearchBot.search_bot?(http_user_agent) end def self.to_agent(http_user_agent) if self.search_bot? http_user_agent SearchBot.new(http_user_agent) else Agent.new(http_user_agent) end end def self.to_agent_s(http_user_agent) agent = self.to_agent http_user_agent "(%s, %s)" % [agent.name, agent.os] end # this ensures the below module methods actually make sense... raise "Class #{base.name} should implement instance method 'http_user_agent'" unless base.instance_methods.map(&:to_s).include? 'http_user_agent' end end |
Instance Method Details
#search_bot? ⇒ Boolean
113 114 115 |
# File 'lib/ntail/http_user_agent.rb', line 113 def search_bot? self.class.search_bot?(self.http_user_agent) end |
#to_agent ⇒ Object
117 118 119 |
# File 'lib/ntail/http_user_agent.rb', line 117 def to_agent self.class.to_agent(self.http_user_agent) end |
#to_agent_s ⇒ Object
121 122 123 |
# File 'lib/ntail/http_user_agent.rb', line 121 def to_agent_s self.class.to_agent_s(self.http_user_agent) end |