Class: Uaid::UserAgent
- Inherits:
-
Object
- Object
- Uaid::UserAgent
- Defined in:
- lib/uaid/user_agent.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(agent) ⇒ UserAgent
constructor
A new instance of UserAgent.
- #method_missing(method, *args) ⇒ Object
- #supported? ⇒ Boolean
- #unsupported? ⇒ Boolean
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
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
5 6 7 |
# File 'lib/uaid/user_agent.rb', line 5 def agent @agent end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/uaid/user_agent.rb', line 5 def name @name end |
#version ⇒ Object (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
12 13 14 |
# File 'lib/uaid/user_agent.rb', line 12 def supported? @supported end |
#unsupported? ⇒ Boolean
16 17 18 |
# File 'lib/uaid/user_agent.rb', line 16 def unsupported? !supported? end |