Class: Browser::Delay
Overview
Allows you to delay the call to a function which gets called after the given time.
Instance Attribute Summary collapse
-
#after ⇒ Float
readonly
The seconds after which the block is called.
Instance Method Summary collapse
-
#abort ⇒ Object
Abort the timeout.
-
#initialize(window, time, &block) ⇒ Delay
constructor
Create and start a timeout.
-
#start ⇒ Object
Start the delay.
Constructor Details
Instance Attribute Details
#after ⇒ Float (readonly)
Returns the seconds after which the block is called.
10 11 12 |
# File 'lib/diamonds/opal/browser/delay.rb', line 10 def after @after end |
Instance Method Details
#abort ⇒ Object
Abort the timeout.
23 24 25 |
# File 'lib/diamonds/opal/browser/delay.rb', line 23 def abort `#@window.clearTimeout(#@id)` end |
#start ⇒ Object
Start the delay.
28 29 30 |
# File 'lib/diamonds/opal/browser/delay.rb', line 28 def start @id = `#@window.setTimeout(#{@block.to_n}, #@after * 1000)` end |