class UserAgentParser::UserAgent

Constants

DEFAULT_FAMILY

Attributes

device[R]
family[R]
name[R]
os[R]
version[R]

Public Class Methods

new(family = nil, version = nil, os = nil, device = nil) click to toggle source
# File lib/user_agent_parser/user_agent.rb, line 11
def initialize(family = nil, version = nil, os = nil, device = nil)
  @family = family || DEFAULT_FAMILY
  @version = version
  @os = os
  @device = device
end

Public Instance Methods

==(other)
Alias for: eql?
eql?(other) click to toggle source
# File lib/user_agent_parser/user_agent.rb, line 31
def eql?(other)
  self.class.eql?(other.class) &&
    family == other.family &&
    version == other.version &&
    os == other.os
end
Also aliased as: ==
inspect() click to toggle source
# File lib/user_agent_parser/user_agent.rb, line 24
def inspect
  string = to_s
  string += " (#{os})" if os
  string += " (#{device})" if device
  "#<#{self.class} #{string}>"
end
to_h() click to toggle source
# File lib/user_agent_parser/user_agent.rb, line 40
def to_h
  {
    device: device.to_h,
    family: family,
    os: os.to_h,
    version: version.to_h
  }
end
to_s() click to toggle source
# File lib/user_agent_parser/user_agent.rb, line 18
def to_s
  string = family
  string += " #{version}" if version
  string
end