Skip to content

Commit cdbc17d

Browse files
committed
prefer case over elseif structure
1 parent 79a5ff8 commit cdbc17d

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

lib/browserino/definitions/filters.rb

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,29 @@
6262
end
6363

6464
filter :platform do |val|
65-
if %r{ip(?:[ao]d|hone)}i =~ val then :ios
66-
elsif %r{^symbian$}i =~ val then :symbianos
67-
elsif %r{w(?:eb)?os}i =~ val then :webos
68-
elsif %r{ubuntu|debian}i =~ val then :linux
69-
elsif %r{mac_os_x}i =~ val then :macintosh
70-
elsif %r{s(?:unos|olaris)}i =~ val then :solaris
71-
elsif %r{cros}i =~ val then :chromeos
72-
elsif %r{kindle|kf\w+}i =~ val then :fire_os
73-
elsif %r{fxos}i =~ val then :firefox_os
65+
case val
66+
when %r{ip(?:[ao]d|hone)}i then :ios
67+
when %r{^symbian$}i then :symbianos
68+
when %r{w(?:eb)?os}i then :webos
69+
when %r{ubuntu|debian}i then :linux
70+
when %r{mac_os_x}i then :macintosh
71+
when %r{s(?:unos|olaris)}i then :solaris
72+
when %r{cros}i then :chromeos
73+
when %r{kindle|kf\w+}i then :fire_os
74+
when %r{fxos}i then :firefox_os
7475
else val
7576
end
7677
end
7778

7879
filter :device do |val|
79-
if %r{kf\w*}i =~ val then :kindle
80-
elsif %r{lg[-l_]}i =~ val then :lg
81-
elsif %r{\w+tab}i =~ val then :lenovo
82-
elsif %r{lumia}i =~ val then :nokia
83-
elsif %r{^moto}i =~ val then :motorola
84-
elsif %r{\d+dl|venue}i =~ val then :dell
85-
elsif %r{me\d+x|a\df;|transformer|slider}i =~ val then :asus
80+
case val
81+
when %r{kf\w*}i then :kindle
82+
when %r{lg[-l_]}i then :lg
83+
when %r{\w+tab}i then :lenovo
84+
when %r{lumia}i then :nokia
85+
when %r{^moto}i then :motorola
86+
when %r{\d+dl|venue}i then :dell
87+
when %r{me\d+x|a\df;|transformer|slider}i then :asus
8688
else val
8789
end
8890
end

0 commit comments

Comments
 (0)