Class: UserAgentParser::OperatingSystem

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

Constant Summary collapse

DEFAULT_FAMILY =
'Other'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(family = DEFAULT_FAMILY, version = nil) ⇒ OperatingSystem

Returns a new instance of OperatingSystem.


11
12
13
14
# File 'lib/user_agent_parser/operating_system.rb', line 11

def initialize(family = DEFAULT_FAMILY, version = nil)
  @family = family
  @version = version
end

Instance Attribute Details

#familyObject (readonly) Also known as: name

Returns the value of attribute family.


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

def family
  @family
end

#versionObject (readonly)

Returns the value of attribute version.


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

def version
  @version
end

Instance Method Details

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

Returns:

  • (Boolean)

26
27
28
29
30
# File 'lib/user_agent_parser/operating_system.rb', line 26

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

#inspectObject


22
23
24
# File 'lib/user_agent_parser/operating_system.rb', line 22

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

#to_hObject


34
35
36
37
38
39
# File 'lib/user_agent_parser/operating_system.rb', line 34

def to_h
  {
    version: version.to_h,
    family: family
  }
end

#to_sObject


16
17
18
19
20
# File 'lib/user_agent_parser/operating_system.rb', line 16

def to_s
  string = family
  string += " #{version}" unless version.nil?
  string
end