module DXOpal
Constants
- P_CT
Like `Kernel.p`, but prints only limited times for each `key` This is useful for debugging your game without flooding the developer console.
Example:
p_ player_x: @player.x p_({player_x: @player.x}, 20)
- VERSION
Public Class Methods
dump_error(&block)
click to toggle source
Call block and dump backtrace if an exception is raised. Nothing is shown if a tag with `id='dxopal-errors'` does not exist
# File lib/dxopal.rb, line 39 def self.dump_error(&block) block.call rescue Exception => ex div = `document.getElementById('dxopal-errors')` if `div && !ex.DXOpalPrinted` %x{ div.textContent = "ERROR: " + #{ex.class.name}; var ul = document.createElement('ul'); // Note: ex.backtrace may be an Array or a String #{Array(ex.backtrace)}.forEach(function(line){ var li = document.createElement('li'); li.textContent = line; ul.appendChild(li); }); div.appendChild(ul); ex.DXOpalPrinted = true; } end raise ex end
Public Instance Methods
p_(hash, n=10)
click to toggle source
# File lib/dxopal.rb, line 68 def p_(hash, n=10) key = hash.keys.sort.join return if P_CT[key] >= n `console.log(#{hash.inspect})` P_CT[key] += 1 end