Class: HTTPLogAnalyzer::Element::Referer
- Inherits:
-
HTTPLogAnalyzer::Element
- Object
- HTTPLogAnalyzer::Element
- HTTPLogAnalyzer::Element::Referer
- Defined in:
- lib/http-log-analyzer/element/referer.rb
Constant Summary collapse
- QueryKeys =
%w{q p searchfor wd}
Instance Attribute Summary collapse
-
#query ⇒ Object
Returns the value of attribute query.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
Methods inherited from HTTPLogAnalyzer::Element
Instance Attribute Details
#query ⇒ Object
Returns the value of attribute query.
10 11 12 |
# File 'lib/http-log-analyzer/element/referer.rb', line 10 def query @query end |
#uri ⇒ Object
Returns the value of attribute uri.
9 10 11 |
# File 'lib/http-log-analyzer/element/referer.rb', line 9 def uri @uri end |
Instance Method Details
#parse(string) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/http-log-analyzer/element/referer.rb', line 12 def parse(string) if string != '-' @uri = Addressable::URI.parse(string) or raise ParseError, "Can't parse URI: #{string}" normalize_uri!(@uri) if @uri.host # normalize Facebook link-shims if @uri.host =~ /^(l|lm)\.facebook\.com$/ || @uri.path.start_with?('/l.php') @uri.host = 'facebook.com' @uri.path = '/' @uri.query = nil end if (values = @uri.query_values) QueryKeys.each do |key| if (value = values[key]) && !value.empty? @query = values[key] break end end end end end end |