Sha256: 32d7441cfc6f5a3d2317e1db7d734952226109260a127ad91121385bf0268272

Contents?: true

Size: 749 Bytes

Versions: 5

Compression:

Stored size: 749 Bytes

Contents

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

    alias_method :name, :family

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

    def to_s
      string = family
      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) &&
      family == other.family &&
        version == other.version &&
        os == other.os
    end

    alias_method :==, :eql?
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
user_agent_parser-2.4.0 lib/user_agent_parser/user_agent.rb
user_agent_parser-2.3.2 lib/user_agent_parser/user_agent.rb
user_agent_parser-2.3.1 lib/user_agent_parser/user_agent.rb
user_agent_parser-2.3.0 lib/user_agent_parser/user_agent.rb
user_agent_parser-2.2.0 lib/user_agent_parser/user_agent.rb