Class: YahooQueryParser

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/filters/parsers/yahoo.rb

Instance Method Summary collapse

Constructor Details

#initializeYahooQueryParser

Returns a new instance of YahooQueryParser.



7
8
9
10
# File 'lib/logstash/filters/parsers/yahoo.rb', line 7

def initialize
  @re_url = /(?:[^\.]*\.)?search.yahoo\..*/
  @re_query = /^\/search\?(?:[^&]*&)?p=(?<query>[^&#]*)/i
end

Instance Method Details

#match(siteName) ⇒ Object



13
14
15
# File 'lib/logstash/filters/parsers/yahoo.rb', line 13

def match(siteName)
  return @re_url.match(siteName)
end

#parse(query) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/logstash/filters/parsers/yahoo.rb', line 17

def parse(query)
  query = Utils.removeInvalidChars(query)
  m = @re_query.match(query)
  if m then
    return m["query"].tr("+", " ").split.join(" ")
  end
end