File: samsung.rb

package info (click to toggle)
ruby-browser 5.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 872 kB
  • sloc: ruby: 4,752; makefile: 13
file content (33 lines) | stat: -rw-r--r-- 575 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module Browser
  class Device
    class Samsung < Base
      REGEX = /\(Linux.*?; Android.*?; (SAMSUNG )?(SM-[A-Z0-9]+).*?\)/i.freeze

      def self.names
        @names ||= YAML.load_file(Browser.root.join("samsung.yml").to_s)
      end

      def id
        :samsung
      end

      def name
        "Samsung #{self.class.names[code] || code}"
      end

      def code
        matches && matches[2]
      end

      def matches
        @matches ||= ua.match(REGEX)
      end

      def match?
        !!matches
      end
    end
  end
end