Class: UserAgent

Inherits:
Object
  • Object
show all
Defined in:
lib/kill_switch/user_agent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_agent_string) ⇒ UserAgent

Returns a new instance of UserAgent.



8
9
10
11
# File 'lib/kill_switch/user_agent.rb', line 8

def initialize(user_agent_string)
  @string = user_agent_string
  parse_string
end

Instance Attribute Details

#app_versionObject (readonly)

Returns the value of attribute app_version.



2
3
4
# File 'lib/kill_switch/user_agent.rb', line 2

def app_version
  @app_version
end

#device_modelObject (readonly)

Returns the value of attribute device_model.



3
4
5
# File 'lib/kill_switch/user_agent.rb', line 3

def device_model
  @device_model
end

#device_os_versionObject (readonly)

Returns the value of attribute device_os_version.



4
5
6
# File 'lib/kill_switch/user_agent.rb', line 4

def device_os_version
  @device_os_version
end

#device_platformObject (readonly)

Returns the value of attribute device_platform.



5
6
7
# File 'lib/kill_switch/user_agent.rb', line 5

def device_platform
  @device_platform
end

#stringObject (readonly)

Returns the value of attribute string.



6
7
8
# File 'lib/kill_switch/user_agent.rb', line 6

def string
  @string
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
# 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