Sha256: b1b0124d812ded8c569155fd631d60b9614cb050a094ca1af7ee9917666de0b1

Contents?: true

Size: 526 Bytes

Versions: 4

Compression:

Stored size: 526 Bytes

Contents

# frozen_string_literal: true

require 'user_agent_parser'

module BrowserslistUseragent
  # Normalizes user agent version to semantically valid state
  class VersionNormalizer
    attr_reader :version

    def initialize(version)
      @version = version
    end

    def call
      agent_version = ::UserAgentParser::Version.new(version)
      return nil if agent_version.major.nil?

      [
        agent_version.major,
        agent_version.minor || 0,
        agent_version.patch || 0
      ].join('.')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
browserslist_useragent-0.2.0 lib/browserslist_useragent/version_normalizer.rb
browserslist_useragent-0.1.3 lib/browserslist_useragent/version_normalizer.rb
browserslist_useragent-0.1.1 lib/browserslist_useragent/version_normalizer.rb
browserslist_useragent-0.1.0 lib/browserslist_useragent/version_normalizer.rb