Class: Uaid::UserAgent

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agent) ⇒ UserAgent

Returns a new instance of UserAgent.



7
8
9
10
# File 'lib/uaid/user_agent.rb', line 7

def initialize(agent)
  @agent = agent
  @name, @version, @supported = extract(@agent ? @agent.strip : '')
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/uaid/user_agent.rb', line 20

def method_missing(method, *args)
  if method.to_s =~ /^(\w+)\?$/ && EXTRACTIONS.find {|patterns, values| values.first == $1}
    name == $1
  else
    super
  end
end

Instance Attribute Details

#agentObject (readonly)

Returns the value of attribute agent.



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

def agent
  @agent
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#supported?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/uaid/user_agent.rb', line 12

def supported?
  @supported
end

#unsupported?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/uaid/user_agent.rb', line 16

def unsupported?
  !supported?
end