Class: UserAgentParser::Device
- Inherits:
-
Object
- Object
- UserAgentParser::Device
- Defined in:
- lib/user_agent_parser/device.rb
Constant Summary collapse
- DEFAULT_FAMILY =
'Other'
Instance Attribute Summary collapse
-
#brand ⇒ Object
readonly
Returns the value of attribute brand.
-
#family ⇒ Object
(also: #name)
readonly
Returns the value of attribute family.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(family = nil, model = nil, brand = nil) ⇒ Device
constructor
A new instance of Device.
- #inspect ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(family = nil, model = nil, brand = nil) ⇒ Device
Returns a new instance of Device.
11 12 13 14 15 |
# File 'lib/user_agent_parser/device.rb', line 11 def initialize(family = nil, model = nil, brand = nil) @family = family || DEFAULT_FAMILY @model = model || @family @brand = brand end |
Instance Attribute Details
#brand ⇒ Object (readonly)
Returns the value of attribute brand.
7 8 9 |
# File 'lib/user_agent_parser/device.rb', line 7 def brand @brand end |
#family ⇒ Object (readonly) Also known as: name
Returns the value of attribute family.
7 8 9 |
# File 'lib/user_agent_parser/device.rb', line 7 def family @family end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
7 8 9 |
# File 'lib/user_agent_parser/device.rb', line 7 def model @model end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
25 26 27 |
# File 'lib/user_agent_parser/device.rb', line 25 def eql?(other) self.class.eql?(other.class) && family == other.family end |
#inspect ⇒ Object
21 22 23 |
# File 'lib/user_agent_parser/device.rb', line 21 def inspect "#<#{self.class} #{self}>" end |
#to_h ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/user_agent_parser/device.rb', line 31 def to_h { family: family, model: model, brand: brand } end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/user_agent_parser/device.rb', line 17 def to_s family end |