Class: UserAgent

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

Instance Attribute Summary collapse

Class Method 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

Class Method Details

.map(name, options = {}) ⇒ Object

Map agent name to options.



40
41
42
# File 'lib/active_device/user_agent.rb', line 40

def self.map name, options = {}
  @agents << [name, options]
end

Instance Method Details

#==(other) ⇒ Object

Check if the agent is the same as other agent.



31
32
33
# File 'lib/active_device/user_agent.rb', line 31

def == other
  user_agent == other.user_agent
end

#inspectObject

Inspect.



24
25
26
# File 'lib/active_device/user_agent.rb', line 24

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

#to_sObject

User agent user_agent.



17
18
19
# File 'lib/active_device/user_agent.rb', line 17

def to_s
  user_agent
end