Class: UserAgentParser::UserAgent
- Inherits:
-
Object
- Object
- UserAgentParser::UserAgent
- Defined in:
- lib/user_agent_parser/user_agent.rb
Instance Attribute Summary collapse
-
#device ⇒ Object
readonly
Returns the value of attribute device.
-
#family ⇒ Object
(also: #name)
readonly
Returns the value of attribute family.
-
#os ⇒ Object
readonly
Returns the value of attribute os.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(family = nil, version = nil, os = nil, device = nil) ⇒ UserAgent
constructor
A new instance of UserAgent.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(family = nil, version = nil, os = nil, device = nil) ⇒ UserAgent
Returns a new instance of UserAgent.
7 8 9 10 11 12 |
# File 'lib/user_agent_parser/user_agent.rb', line 7 def initialize(family = nil, version = nil, os = nil, device = nil) @family = family || 'Other' @version = version @os = os @device = device end |
Instance Attribute Details
#device ⇒ Object (readonly)
Returns the value of attribute device.
3 4 5 |
# File 'lib/user_agent_parser/user_agent.rb', line 3 def device @device end |
#family ⇒ Object (readonly) Also known as: name
Returns the value of attribute family.
3 4 5 |
# File 'lib/user_agent_parser/user_agent.rb', line 3 def family @family end |
#os ⇒ Object (readonly)
Returns the value of attribute os.
3 4 5 |
# File 'lib/user_agent_parser/user_agent.rb', line 3 def os @os end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
3 4 5 |
# File 'lib/user_agent_parser/user_agent.rb', line 3 def version @version end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
27 28 29 30 31 32 |
# File 'lib/user_agent_parser/user_agent.rb', line 27 def eql?(other) self.class.eql?(other.class) && family == other.family && version == other.version && os == other.os end |
#inspect ⇒ Object
20 21 22 23 24 25 |
# File 'lib/user_agent_parser/user_agent.rb', line 20 def inspect string = to_s string += " (#{os})" if os string += " (#{device})" if device "#<#{self.class} #{string}>" end |
#to_s ⇒ Object
14 15 16 17 18 |
# File 'lib/user_agent_parser/user_agent.rb', line 14 def to_s string = family string += " #{version}" if version string end |