rubyx-debugger/app/main/controllers/objects_controller.rb

48 lines
1.2 KiB
Ruby
Raw Normal View History

2015-08-18 23:08:12 +02:00
if RUBY_PLATFORM == 'opal'
require "native"
end
2015-08-16 09:01:12 +02:00
module Main
class ObjectsController < Volt::ModelController
2015-08-18 23:08:12 +02:00
def index_ready
container = Native(self.container).querySelector("ul")
return unless container
puts "li " + container.innerHTML + " lo"
# red = -> (event) { container.style.backgroundColor = "red" }
red = -> (event) { puts container.tagName }
container.addEventListener("mouseenter" , red)
end
2015-08-19 00:08:28 +02:00
def marker id
var = Virtual.machine.objects[id]
if var.is_a? String
str "Wo"
else
str = var.class.name.split("::").last[0,2]
end
str + " : #{id.to_s}"
2015-08-16 09:01:12 +02:00
end
def content(id)
object = Virtual.machine.objects[id]
fields = []
if object and ! object.is_a?(String)
clazz = object.class.name.split("::").last
2015-08-19 00:08:28 +02:00
fields << ["#{clazz}:#{object.object_id}" , 0]
2015-08-16 09:01:12 +02:00
fields << ["--------------------" , 0 ]
object.get_instance_variables.each do |variable|
f = object.get_instance_variable(variable)
fields << ["#{variable} : #{marker(f.object_id)}" , f.object_id]
2015-08-16 09:01:12 +02:00
end
end
fields
end
def is_object?( id )
Virtual.machine.objects[id] != nil
end
end
end