Class: UserAgentParser::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/user_agent_parser/device.rb

Constant Summary collapse

DEFAULT_FAMILY =
'Other'

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#brandObject (readonly)

Returns the value of attribute brand.



7
8
9
# File 'lib/user_agent_parser/device.rb', line 7

def brand
  @brand
end

#familyObject (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

#modelObject (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: ==

Returns:

  • (Boolean)


25
26
27
# File 'lib/user_agent_parser/device.rb', line 25

def eql?(other)
  self.class.eql?(other.class) && family == other.family
end

#inspectObject



21
22
23
# File 'lib/user_agent_parser/device.rb', line 21

def inspect
  "#<#{self.class} #{self}>"
end

#to_hObject



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_sObject



17
18
19
# File 'lib/user_agent_parser/device.rb', line 17

def to_s
  family
end