Class: Browser::Device
- Inherits:
-
Object
show all
- Defined in:
- lib/browser/device.rb,
lib/browser/device/tv.rb,
lib/browser/device/psp.rb,
lib/browser/device/wii.rb,
lib/browser/device/base.rb,
lib/browser/device/ipad.rb,
lib/browser/device/wiiu.rb,
lib/browser/device/iphone.rb,
lib/browser/device/kindle.rb,
lib/browser/device/psvita.rb,
lib/browser/device/switch.rb,
lib/browser/device/android.rb,
lib/browser/device/surface.rb,
lib/browser/device/unknown.rb,
lib/browser/device/xbox_360.rb,
lib/browser/device/xbox_one.rb,
lib/browser/device/ipod_touch.rb,
lib/browser/device/kindle_fire.rb,
lib/browser/device/playstation3.rb,
lib/browser/device/playstation4.rb,
lib/browser/device/blackberry_playbook.rb
Defined Under Namespace
Classes: Android, Base, BlackBerryPlaybook, Ipad, Iphone, IpodTouch, Kindle, KindleFire, PSP, PSVita, PlayStation3, PlayStation4, Surface, Switch, TV, Unknown, Wii, WiiU, Xbox360, XboxOne
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(ua) ⇒ Device
Returns a new instance of Device.
54
55
56
|
# File 'lib/browser/device.rb', line 54
def initialize(ua)
@ua = ua
end
|
Class Method Details
.matchers ⇒ Object
Hold the list of device matchers. Order is important.
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/browser/device.rb', line 30
def self.matchers
@matchers ||= [
XboxOne,
Xbox360,
Surface,
TV,
BlackBerryPlaybook,
WiiU,
Wii,
Switch,
KindleFire,
Kindle,
PlayStation4,
PlayStation3,
PSVita,
PSP,
Ipad,
Iphone,
IpodTouch,
Android,
Unknown
]
end
|
Instance Method Details
#blackberry_playbook? ⇒ Boolean
Also known as:
playbook?
146
147
148
|
# File 'lib/browser/device.rb', line 146
def blackberry_playbook?
id == :playbook
end
|
#console? ⇒ Boolean
Detect if browser is console (currently Xbox, PlayStation, or Nintendo).
190
191
192
|
# File 'lib/browser/device.rb', line 190
def console?
xbox? || playstation? || nintendo?
end
|
#id ⇒ Object
64
65
66
|
# File 'lib/browser/device.rb', line 64
def id
subject.id
end
|
#ipad? ⇒ Boolean
86
87
88
|
# File 'lib/browser/device.rb', line 86
def ipad?
id == :ipad
end
|
#iphone? ⇒ Boolean
99
100
101
|
# File 'lib/browser/device.rb', line 99
def iphone?
id == :iphone
end
|
#ipod_touch? ⇒ Boolean
Also known as:
ipod?
94
95
96
|
# File 'lib/browser/device.rb', line 94
def ipod_touch?
id == :ipod_touch
end
|
#kindle? ⇒ Boolean
123
124
125
|
# File 'lib/browser/device.rb', line 123
def kindle?
id == :kindle || kindle_fire?
end
|
#kindle_fire? ⇒ Boolean
127
128
129
|
# File 'lib/browser/device.rb', line 127
def kindle_fire?
id == :kindle_fire
end
|
#mobile? ⇒ Boolean
Detect if browser is mobile.
82
83
84
|
# File 'lib/browser/device.rb', line 82
def mobile?
detect_mobile? && !tablet?
end
|
#name ⇒ Object
68
69
70
|
# File 'lib/browser/device.rb', line 68
def name
subject.name
end
|
#nintendo? ⇒ Boolean
Detect if browser is Nintendo.
185
186
187
|
# File 'lib/browser/device.rb', line 185
def nintendo?
wii? || wiiu? || switch?
end
|
#nintendo_switch? ⇒ Boolean
Also known as:
switch?
141
142
143
|
# File 'lib/browser/device.rb', line 141
def nintendo_switch?
id == :switch
end
|
#nintendo_wii? ⇒ Boolean
Also known as:
wii?
131
132
133
|
# File 'lib/browser/device.rb', line 131
def nintendo_wii?
id == :wii
end
|
#nintendo_wiiu? ⇒ Boolean
Also known as:
wiiu?
136
137
138
|
# File 'lib/browser/device.rb', line 136
def nintendo_wiiu?
id == :wiiu
end
|
#playstation? ⇒ Boolean
Detect if browser is running under PlayStation.
180
181
182
|
# File 'lib/browser/device.rb', line 180
def playstation?
ps3? || ps4?
end
|
#playstation_vita? ⇒ Boolean
Also known as:
vita?, psp_vita?
117
118
119
|
# File 'lib/browser/device.rb', line 117
def playstation_vita?
id == :psvita
end
|
#ps3? ⇒ Boolean
Also known as:
playstation3?
103
104
105
|
# File 'lib/browser/device.rb', line 103
def ps3?
id == :ps3
end
|
#ps4? ⇒ Boolean
Also known as:
playstation4?
108
109
110
|
# File 'lib/browser/device.rb', line 108
def ps4?
id == :ps4
end
|
#psp? ⇒ Boolean
113
114
115
|
# File 'lib/browser/device.rb', line 113
def psp?
id == :psp
end
|
#silk? ⇒ Boolean
Detect if browser is Silk.
160
161
162
|
# File 'lib/browser/device.rb', line 160
def silk?
ua =~ /Silk/
end
|
#surface? ⇒ Boolean
151
152
153
|
# File 'lib/browser/device.rb', line 151
def surface?
id == :surface
end
|
#tablet? ⇒ Boolean
Detect if browser is tablet (currently iPad, Android, Surface or Playbook).
74
75
76
77
78
79
|
# File 'lib/browser/device.rb', line 74
def tablet?
ipad? ||
(platform.android? && !detect_mobile?) ||
surface? ||
playbook?
end
|
#tv? ⇒ Boolean
155
156
157
|
# File 'lib/browser/device.rb', line 155
def tv?
id == :tv
end
|
#unknown? ⇒ Boolean
90
91
92
|
# File 'lib/browser/device.rb', line 90
def unknown?
id == :unknown
end
|
#xbox? ⇒ Boolean
Detect if browser is running under Xbox.
165
166
167
|
# File 'lib/browser/device.rb', line 165
def xbox?
ua =~ /Xbox/
end
|
#xbox_360? ⇒ Boolean
Detect if browser is running under Xbox 360.
170
171
172
|
# File 'lib/browser/device.rb', line 170
def xbox_360?
id == :xbox_360
end
|
#xbox_one? ⇒ Boolean
Detect if browser is running under Xbox One.
175
176
177
|
# File 'lib/browser/device.rb', line 175
def xbox_one?
id == :xbox_one
end
|