Class: UserAgent

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_agent) ⇒ UserAgent

Initialize with user agent user_agent.



10
11
12
# File 'lib/active_device/user_agent.rb', line 10

def initialize user_agent
  @user_agent = user_agent.strip
end

Instance Attribute Details

#user_agentObject (readonly)

User agent user_agent.



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

def user_agent
  @user_agent
end

Instance Method Details

#==(other) ⇒ Object

Check if the agent is the same as other agent.



113
114
115
# File 'lib/active_device/user_agent.rb', line 113

def == other
  user_agent == other.user_agent
end

#brandObject

User agent brand symbol.



84
85
86
# File 'lib/active_device/user_agent.rb', line 84

def brand
  Brand.mobile_brand user_agent
end

#engineObject

User agent engine symbol.



35
36
37
# File 'lib/active_device/user_agent.rb', line 35

def engine
  AgentSpec.engine_for_user_agent user_agent
end

#engine_versionObject

User agent engine version user_agent.



42
43
44
# File 'lib/active_device/user_agent.rb', line 42

def engine_version
  AgentSpec.engine_version_for_user_agent user_agent
end

#inspectObject

Inspect.



106
107
108
# File 'lib/active_device/user_agent.rb', line 106

def inspect
  "#<Agent:#{name} version:#{version.inspect} engine:\"#{engine.to_s}:#{engine_version}\" os:#{os.to_s.inspect}>"
end

#is_handset?(model) ⇒ Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/active_device/user_agent.rb', line 92

def is_handset? model
  Handset.is_handset? user_agent, model
end

#is_mobile?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/active_device/user_agent.rb', line 88

def is_mobile?
  Handset.is_mobile? user_agent
end

#modelObject

User agent model symbol.



70
71
72
# File 'lib/active_device/user_agent.rb', line 70

def model
  Model.brand_model user_agent
end

#model_reselutionObject

User agent model Reselution symbol.



77
78
79
# File 'lib/active_device/user_agent.rb', line 77

def model_reselution
  Model.model_reselution user_agent
end

#nameObject

User agent name symbol.



21
22
23
# File 'lib/active_device/user_agent.rb', line 21

def name
  AgentSpec.name_for_user_agent user_agent
end

#osObject

User agent os symbol.



49
50
51
# File 'lib/active_device/user_agent.rb', line 49

def os
  AgentSpec.os_for_user_agent user_agent
end

#os_seriesObject

User agent engine version user_agent.



63
64
65
# File 'lib/active_device/user_agent.rb', line 63

def os_series
  AgentSpec.os_series_for_user_agent user_agent
end

#os_versionObject

User agent engine version user_agent.



56
57
58
# File 'lib/active_device/user_agent.rb', line 56

def os_version
  AgentSpec.os_version_for_user_agent user_agent
end

#to_sObject

User agent user_agent.



99
100
101
# File 'lib/active_device/user_agent.rb', line 99

def to_s
  user_agent
end

#versionObject

User agent version.



28
29
30
# File 'lib/active_device/user_agent.rb', line 28

def version
  AgentSpec.version_for_user_agent user_agent
end