Class: Console
Overview
Manipulate the browser console.
Instance Method Summary collapse
-
#clear ⇒ Object
Clear the console.
-
#error(*args) ⇒ Object
Log the passed objects based on an optional initial format as error.
-
#group(*args, &block) ⇒ Object
Group the given block.
-
#group!(*args, &block) ⇒ Object
Group the given block but collapse it.
-
#info(*args) ⇒ Object
Log the passed objects based on an optional initial format as informational log.
-
#log(*args) ⇒ Object
Log the passed objects based on an optional initial format.
-
#time(label, &block) ⇒ Object
Time the given block with the given label.
-
#trace ⇒ Object
Print a stacktrace from the call site.
-
#warn(*args) ⇒ Object
Log the passed objects based on an optional initial format as warning.
Methods included from Native
call, convert, included, #initialize, is_a?, proc, #to_n, try_convert
Instance Method Details
#clear ⇒ Object
Clear the console.
10 11 12 |
# File 'opal/stdlib/console.rb', line 10 def clear `#@native.clear()` end |
#error(*args) ⇒ Object
Log the passed objects based on an optional initial format as error.
36 37 38 |
# File 'opal/stdlib/console.rb', line 36 def error(*args) `#@native.error.apply(#@native, args)` end |
#group(*args, &block) ⇒ Object
Group the given block.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'opal/stdlib/console.rb', line 58 def group(*args, &block) raise ArgumentError, "no block given" unless block `#@native.group.apply(#@native, args)` begin if block.arity == 0 instance_exec(&block) else block.call(self) end ensure `#@native.groupEnd()` end end |
#group!(*args, &block) ⇒ Object
Group the given block but collapse it.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'opal/stdlib/console.rb', line 75 def group!(*args, &block) return unless block_given? `#@native.groupCollapsed.apply(#@native, args)` begin if block.arity == 0 instance_exec(&block) else block.call(self) end ensure `#@native.groupEnd()` end end |
#info(*args) ⇒ Object
Log the passed objects based on an optional initial format as informational log.
26 27 28 |
# File 'opal/stdlib/console.rb', line 26 def info(*args) `#@native.info.apply(#@native, args)` end |
#log(*args) ⇒ Object
Log the passed objects based on an optional initial format.
20 21 22 |
# File 'opal/stdlib/console.rb', line 20 def log(*args) `#@native.log.apply(#@native, args)` end |
#time(label, &block) ⇒ Object
Time the given block with the given label.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'opal/stdlib/console.rb', line 41 def time(label, &block) raise ArgumentError, "no block given" unless block `#@native.time(label)` begin if block.arity == 0 instance_exec(&block) else block.call(self) end ensure `#@native.timeEnd()` end end |
#trace ⇒ Object
Print a stacktrace from the call site.
15 16 17 |
# File 'opal/stdlib/console.rb', line 15 def trace `#@native.trace()` end |
#warn(*args) ⇒ Object
Log the passed objects based on an optional initial format as warning.
31 32 33 |
# File 'opal/stdlib/console.rb', line 31 def warn(*args) `#@native.warn.apply(#@native, args)` end |