Class: HTTPLogAnalyzer::Element::UserAgent
- Inherits:
-
HTTPLogAnalyzer::Element
- Object
- HTTPLogAnalyzer::Element
- HTTPLogAnalyzer::Element::UserAgent
- Defined in:
- lib/http-log-analyzer/element/user_agent.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
Returns the value of attribute browser.
-
#system ⇒ Object
Returns the value of attribute system.
Instance Method Summary collapse
Methods inherited from HTTPLogAnalyzer::Element
Instance Attribute Details
#browser ⇒ Object
Returns the value of attribute browser.
7 8 9 |
# File 'lib/http-log-analyzer/element/user_agent.rb', line 7 def browser @browser end |
#system ⇒ Object
Returns the value of attribute system.
8 9 10 |
# File 'lib/http-log-analyzer/element/user_agent.rb', line 8 def system @system end |
Instance Method Details
#parse(string) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/http-log-analyzer/element/user_agent.rb', line 10 def parse(string) if string != '-' user_agent = $user_agent_parser.parse(string) @browser = case (family = user_agent.family.strip) when nil, 'Other' 'other' else family end @system = case (name = user_agent.os.name.strip) when /^Windows\s/ 'Windows' when /^Mac OS/i 'macOS' when 'Other', nil 'other' when 'Ubuntu', 'Fedora', 'SUSE' 'Linux' else name end end end |