Sha256: c063dfa35349c41ef2b0718b95cb0217ed9e17a57ea3155a711fb2696356475d

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

class UserAgent
  module Browsers
    module All
      include Comparable
      
      def <=>(other)
        if respond_to?(:browser) && other.respond_to?(:browser) &&
            browser == other.browser
          version <=> other.version
        else
          false
        end
      end

      def eql?(other)
        self == other
      end

      def to_s
        to_str
      end

      def to_str
        join(" ")
      end

      def application
        first
      end

      def browser
        application.product
      end
      
      def platform
        "Unknown"
      end
      
      def os
        "Unknown"
      end
      
      def version=(v)
        application.version = v
      end
      
      def original
        application.original
      end
      
      def version
        application.version
      end

      def respond_to?(symbol)
        detect_product(symbol) ? true : super
      end

      def method_missing(method, *args, &block)
        detect_product(method) || super
      end

      private
        def detect_product(product)
          detect { |useragent| useragent.product.to_s.downcase == product.to_s.downcase }
        end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
delano-useragent-0.0.2 lib/user_agent/browsers/all.rb
stella-0.3.2 vendor/useragent/lib/user_agent/browsers/all.rb
stella-0.5.1 vendor/useragent/lib/user_agent/browsers/all.rb
stella-0.5.3 vendor/useragent/lib/user_agent/browsers/all.rb
stella-0.5.4 vendor/useragent/lib/user_agent/browsers/all.rb
stella-0.5.5 vendor/useragent/lib/user_agent/browsers/all.rb