Module: Kernel

Defined in:
opal/fron/core_ext/kernel.rb

Overview

Kernel

Instance Method Summary collapse

Instance Method Details

#alert(text) ⇒ Object

Shows an alert window with the given text

Parameters:



31
32
33
# File 'opal/fron/core_ext/kernel.rb', line 31

def alert(text)
  `alert(#{text})`
end

#clear_timeout(id) ⇒ Object

Clears the timeout with the given ID

Parameters:



51
52
53
# File 'opal/fron/core_ext/kernel.rb', line 51

def clear_timeout(id)
  `clearTimeout(#{id})`
end

#confirm(text) ⇒ Boolean

Shows an confirm window with the given text

Parameters:

Returns:

  • (Boolean)

    True of false depending on user input



40
41
42
# File 'opal/fron/core_ext/kernel.rb', line 40

def confirm(text)
  `confirm(#{text})`
end

#loggerFron::Logger

Returns the logger for the application

Returns:



58
59
60
# File 'opal/fron/core_ext/kernel.rb', line 58

def logger
  @logger ||= Fron::Logger.new
end

#open_window(url) ⇒ Object



44
45
46
# File 'opal/fron/core_ext/kernel.rb', line 44

def open_window(url)
  `window.open(#{url})`
end

#prompt(text, value) ⇒ String

Shows a prompt window with text and value

Parameters:

Returns:



24
25
26
# File 'opal/fron/core_ext/kernel.rb', line 24

def prompt(text, value)
  `prompt(#{text}, #{value}) || Opal.NIL`
end

#request_animation_frameObject

Requests an animation frame from the browser and runs the givel block if given.



5
6
7
8
9
# File 'opal/fron/core_ext/kernel.rb', line 5

def request_animation_frame
  return unless block_given?
  return unless `!!window.requestAnimationFrame`
  `window.requestAnimationFrame(function(){ #{yield} })`
end

#timeout(ms = 0) ⇒ Object

Runs the given block after the given number of milliseconds.

Parameters:

  • ms (Integer) (defaults to: 0)

    The milliseconds



14
15
16
# File 'opal/fron/core_ext/kernel.rb', line 14

def timeout(ms = 0)
  `setTimeout(function(){#{yield}},#{ms})`
end

#trace!Object

Produces a JavaScript stack trace in the console



63
64
65
# File 'opal/fron/core_ext/kernel.rb', line 63

def trace!
  `console.trace()`
end