Sha256: ab3df1b65d1496cd297240e2ee1ae4d98fad5fa456de97f73fc29a234998056c

Contents?: true

Size: 802 Bytes

Versions: 7

Compression:

Stored size: 802 Bytes

Contents

module UserAgentParser
  class UserAgent
    attr_reader :name, :version, :os, :device

    # For backwards compatibility with older versions of this gem.
    alias_method :family, :name

    def initialize(name = nil, version = nil, os = nil, device = nil)
      @name = name || 'Other'
      @version = version
      @os = os
      @device = device
    end

    def to_s
      string = name
      string += " #{version}" if version
      string
    end

    def inspect
      string = to_s
      string += " (#{os})" if os
      string += " (#{device})" if device
      "#<#{self.class} #{string}>"
    end

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

    alias_method :==, :eql?
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
user_agent_parser-2.1.5 lib/user_agent_parser/user_agent.rb
user_agent_parser-2.1.4 lib/user_agent_parser/user_agent.rb
user_agent_parser-2.1.3 lib/user_agent_parser/user_agent.rb
user_agent_parser-2.1.2 lib/user_agent_parser/user_agent.rb
user_agent_parser-2.1.1 lib/user_agent_parser/user_agent.rb
user_agent_parser-2.1.0 lib/user_agent_parser/user_agent.rb
user_agent_parser-2.0.0 lib/user_agent_parser/user_agent.rb