Class: UserAgentParser::OperatingSystem

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(family = 'Other', version = nil) ⇒ OperatingSystem

Returns a new instance of OperatingSystem.



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

def initialize(family = 'Other', version = nil)
  @family = family
  @version = version
end

Instance Attribute Details

#familyObject (readonly) Also known as: name

Returns the value of attribute family.



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

def family
  @family
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

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

Returns:

  • (Boolean)


24
25
26
27
28
# File 'lib/user_agent_parser/operating_system.rb', line 24

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

#inspectObject



20
21
22
# File 'lib/user_agent_parser/operating_system.rb', line 20

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

#to_hObject



32
33
34
35
36
37
# File 'lib/user_agent_parser/operating_system.rb', line 32

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

#to_sObject



14
15
16
17
18
# File 'lib/user_agent_parser/operating_system.rb', line 14

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