File: model_extractor.rb

package info (click to toggle)
ruby-device-detector 1.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,820 kB
  • sloc: ruby: 3,650; makefile: 5
file content (24 lines) | stat: -rw-r--r-- 424 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
# frozen_string_literal: true

class DeviceDetector
  class ModelExtractor < MetadataExtractor
    def call
      s = super.to_s.gsub('_', ' ').strip
      s = s.gsub(/ TD$/i, '')

      return nil if s == 'Build'

      s.empty? ? nil : s
    end

    private

    def metadata_string
      String(regex_meta[:model])
    end

    def regex
      @regex ||= regex_meta[:regex_model] || regex_meta[:regex]
    end
  end
end