Module: Woothee::Appliance

Extended by:
Util
Defined in:
lib/woothee/appliance.rb

Class Method Summary collapse

Methods included from Util

update_category, update_map, update_os, update_os_version, update_version

Class Method Details

.challenge_digitaltv(ua, result) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/woothee/appliance.rb', line 57

def self.challenge_digitaltv(ua, result)
  data = if ua.index('InettvBrowser/')
           Woothee::DataSet.get('DigitalTV')
         else
           nil
         end
  return false unless data

  update_map(result, data)
  true
end

.challenge_nintendo(ua, result) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/woothee/appliance.rb', line 43

def self.challenge_nintendo(ua, result)
  data = case
         when ua.index('Nintendo 3DS;') then Woothee::DataSet.get('Nintendo3DS')
         when ua.index('Nintendo DSi;') then Woothee::DataSet.get('NintendoDSi')
         when ua.index('Nintendo Wii;') then Woothee::DataSet.get('NintendoWii')
         when ua.index('(Nintendo WiiU)') then Woothee::DataSet.get('NintendoWiiU')
         else nil
         end
  return false unless data

  update_map(result, data)
  true
end

.challenge_playstation(ua, result) ⇒ Object



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
34
35
36
37
38
39
40
41
# File 'lib/woothee/appliance.rb', line 9

def self.challenge_playstation(ua, result)
  data = nil
  os_version = nil
  case
  when ua.index('PSP (PlayStation Portable);')
    data = Woothee::DataSet.get('PSP')
    if ua =~ /PSP \(PlayStation Portable\); ([.0-9]+)\)/
      os_version = $1
    end
  when ua.index('PlayStation Vita')
    data = Woothee::DataSet.get('PSVita')
    if ua =~ /PlayStation Vita ([.0-9]+)\)/
      os_version = $1
    end
  when ua.index('PLAYSTATION 3 ') || ua.index('PLAYSTATION 3;')
    data = Woothee::DataSet.get('PS3')
    if ua =~ /PLAYSTATION 3;? ([.0-9]+)\)/
      os_version = $1
    end
  when ua.index('PlayStation 4 ')
    data = Woothee::DataSet.get('PS4')
    if ua =~ /PlayStation 4 ([.0-9]+)\)/
      os_version = $1
    end
  end
  return false unless data

  update_map(result, data)
  if os_version
    update_os_version(result, os_version)
  end
  true
end