class UserAgent
Attributes
app_version[R]
device_model[R]
device_os_version[R]
device_platform[R]
string[R]
Public Class Methods
new(user_agent_string)
click to toggle source
# File lib/kill_switch/user_agent.rb, line 8 def initialize(user_agent_string) @string = user_agent_string parse_string end
Public Instance Methods
valid?()
click to toggle source
# File lib/kill_switch/user_agent.rb, line 13 def valid? @parsed_successfully && !@app_version.to_s.empty? && !@device_model.to_s.empty? && !@device_os_version.to_s.empty? && !@device_platform.to_s.empty? end
Private Instance Methods
parse_string()
click to toggle source
# File lib/kill_switch/user_agent.rb, line 23 def parse_string if match = @string.match(/\/([^ ]+) \(([^)]+)\)/) @app_version, rest = match.captures rest = rest.split(';') @device_platform = rest[0].strip @device_os_version = rest[1].strip @device_model = rest[2].strip @parsed_successfully = true end rescue Exception @parsed_successfully = false end