Class: Dommy::WakeLock
- Inherits:
-
Object
- Object
- Dommy::WakeLock
- Includes:
- Bridge::Methods
- Defined in:
- lib/dommy/navigator.rb
Overview
‘navigator.wakeLock` — Screen Wake Lock API stub. `request(type)` returns a Promise of a `WakeLockSentinel` whose `release()` flips `released` and dispatches a `release` event.
Instance Method Summary collapse
- #__js_call__(method, args) ⇒ Object
-
#initialize(window) ⇒ WakeLock
constructor
A new instance of WakeLock.
- #request(type = "screen") ⇒ Object
Methods included from Bridge::Methods
Constructor Details
#initialize(window) ⇒ WakeLock
Returns a new instance of WakeLock.
440 441 442 |
# File 'lib/dommy/navigator.rb', line 440 def initialize(window) @window = window end |
Instance Method Details
#__js_call__(method, args) ⇒ Object
450 451 452 453 454 455 |
# File 'lib/dommy/navigator.rb', line 450 def __js_call__(method, args) case method when "request" request(args[0] || "screen") end end |
#request(type = "screen") ⇒ Object
444 445 446 |
# File 'lib/dommy/navigator.rb', line 444 def request(type = "screen") PromiseValue.resolve(@window, WakeLockSentinel.new(@window, type.to_s)) end |