Class: GoogleQueryParser
- Inherits:
-
Object
- Object
- GoogleQueryParser
- Defined in:
- lib/logstash/filters/parsers/google.rb
Instance Method Summary collapse
-
#initialize ⇒ GoogleQueryParser
constructor
A new instance of GoogleQueryParser.
- #match(siteName) ⇒ Object
- #parse(query) ⇒ Object
Constructor Details
#initialize ⇒ GoogleQueryParser
Returns a new instance of GoogleQueryParser.
7 8 9 10 |
# File 'lib/logstash/filters/parsers/google.rb', line 7 def initialize @re_url = /(?:www\.)?google\..*/ @re_query = /^\/search\?(?:[^&]*&)?q=(?<query>[^&#]*)/i end |
Instance Method Details
#match(siteName) ⇒ Object
13 14 15 |
# File 'lib/logstash/filters/parsers/google.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/google.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 |