Class: Browser::Device::Samsung

Inherits:
Base
  • Object
show all
Defined in:
lib/browser/device/samsung.rb

Constant Summary collapse

REGEX =
/\(Linux.*?; Android.*?; (SAMSUNG )?(SM-[A-Z0-9]+).*?\)/i.freeze

Instance Attribute Summary

Attributes inherited from Base

#ua

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Browser::Device::Base

Class Method Details

.namesObject



8
9
10
# File 'lib/browser/device/samsung.rb', line 8

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

Instance Method Details

#codeObject



20
21
22
# File 'lib/browser/device/samsung.rb', line 20

def code
  matches && matches[2]
end

#idObject



12
13
14
# File 'lib/browser/device/samsung.rb', line 12

def id
  :samsung
end

#match?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/browser/device/samsung.rb', line 28

def match?
  !!matches
end

#matchesObject



24
25
26
# File 'lib/browser/device/samsung.rb', line 24

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

#nameObject



16
17
18
# File 'lib/browser/device/samsung.rb', line 16

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