Class: UserAgentParser::Device

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(family = nil, model = nil, brand = nil) ⇒ Device

Returns a new instance of Device.



9
10
11
12
13
# File 'lib/user_agent_parser/device.rb', line 9

def initialize(family = nil, model = nil, brand = nil)
  @family = family || 'Other'
  @model = model || @family
  @brand = brand
end

Instance Attribute Details

#brandObject (readonly)

Returns the value of attribute brand.



5
6
7
# File 'lib/user_agent_parser/device.rb', line 5

def brand
  @brand
end

#familyObject (readonly) Also known as: name

Returns the value of attribute family.



5
6
7
# File 'lib/user_agent_parser/device.rb', line 5

def family
  @family
end

#modelObject (readonly)

Returns the value of attribute model.



5
6
7
# File 'lib/user_agent_parser/device.rb', line 5

def model
  @model
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


23
24
25
# File 'lib/user_agent_parser/device.rb', line 23

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

#inspectObject



19
20
21
# File 'lib/user_agent_parser/device.rb', line 19

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

#to_hObject



29
30
31
32
33
34
35
# File 'lib/user_agent_parser/device.rb', line 29

def to_h
  {
    family: family,
    model: model,
    brand: brand
  }
end

#to_sObject



15
16
17
# File 'lib/user_agent_parser/device.rb', line 15

def to_s
  family
end