Class: UserAgentParser::UserAgent
- Inherits:
-
Object
- Object
- UserAgentParser::UserAgent
- Defined in:
- lib/user_agent_parser/user_agent.rb
Constant Summary collapse
- DEFAULT_FAMILY =
'Other'
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_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(family = nil, version = nil, os = nil, device = nil) ⇒ UserAgent
Returns a new instance of UserAgent.
11 12 13 14 15 16 |
# File 'lib/user_agent_parser/user_agent.rb', line 11 def initialize(family = nil, version = nil, os = nil, device = nil) @family = family || DEFAULT_FAMILY @version = version @os = os @device = device end |
Instance Attribute Details
#device ⇒ Object (readonly)
Returns the value of attribute device.
7 8 9 |
# File 'lib/user_agent_parser/user_agent.rb', line 7 def device @device end |
#family ⇒ Object (readonly) Also known as: name
Returns the value of attribute family.
7 8 9 |
# File 'lib/user_agent_parser/user_agent.rb', line 7 def family @family end |
#os ⇒ Object (readonly)
Returns the value of attribute os.
7 8 9 |
# File 'lib/user_agent_parser/user_agent.rb', line 7 def os @os end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
7 8 9 |
# File 'lib/user_agent_parser/user_agent.rb', line 7 def version @version end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
31 32 33 34 35 36 |
# File 'lib/user_agent_parser/user_agent.rb', line 31 def eql?(other) self.class.eql?(other.class) && family == other.family && version == other.version && os == other.os end |
#inspect ⇒ Object
24 25 26 27 28 29 |
# File 'lib/user_agent_parser/user_agent.rb', line 24 def inspect string = to_s string += " (#{os})" if os string += " (#{device})" if device "#<#{self.class} #{string}>" end |
#to_h ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/user_agent_parser/user_agent.rb', line 40 def to_h { device: device.to_h, family: family, os: os.to_h, version: version.to_h } end |
#to_s ⇒ Object
18 19 20 21 22 |
# File 'lib/user_agent_parser/user_agent.rb', line 18 def to_s string = family string += " #{version}" if version string end |