Sha256: 41c050d10df1d11e3f2c5a5d7a867c2e0f0e9ed3093c210c12e3d1a3c0b488cb

Contents?: true

Size: 641 Bytes

Versions: 15

Compression:

Stored size: 641 Bytes

Contents

# frozen_string_literal: true

module UserAgentParser
  class Device
    DEFAULT_FAMILY = 'Other'

    attr_reader :family, :model, :brand

    alias name family

    def initialize(family = nil, model = nil, brand = nil)
      @family = family || DEFAULT_FAMILY
      @model = model || @family
      @brand = brand
    end

    def to_s
      family
    end

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

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

    alias == eql?

    def to_h
      {
        family: family,
        model: model,
        brand: brand
      }
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
user_agent_parser-2.18.0 lib/user_agent_parser/device.rb
user_agent_parser-2.17.0 lib/user_agent_parser/device.rb
user_agent_parser-2.16.0 lib/user_agent_parser/device.rb
user_agent_parser-2.15.0 lib/user_agent_parser/device.rb
user_agent_parser-2.14.0 lib/user_agent_parser/device.rb
user_agent_parser-2.13.0 lib/user_agent_parser/device.rb
user_agent_parser-2.12.0 lib/user_agent_parser/device.rb
user_agent_parser-2.11.0 lib/user_agent_parser/device.rb
user_agent_parser-2.10.0 lib/user_agent_parser/device.rb
user_agent_parser-2.9.0 lib/user_agent_parser/device.rb
user_agent_parser-2.8.0 lib/user_agent_parser/device.rb
user_agent_parser-2.7.0 lib/user_agent_parser/device.rb
user_agent_parser_livelink-2.6.0 lib/user_agent_parser/device.rb
user_agent_parser-2.6.0 lib/user_agent_parser/device.rb
user_agent_parser-2.5.3 lib/user_agent_parser/device.rb