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:
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/ntail/http_user_agent.rb', line 107 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
133 134 135 |
# File 'lib/ntail/http_user_agent.rb', line 133 def search_bot? self.class.search_bot?(self.http_user_agent) end |
#to_agent ⇒ Object
137 138 139 |
# File 'lib/ntail/http_user_agent.rb', line 137 def to_agent self.class.to_agent(self.http_user_agent) end |
#to_agent_s ⇒ Object
141 142 143 |
# File 'lib/ntail/http_user_agent.rb', line 141 def to_agent_s self.class.to_agent_s(self.http_user_agent) end |