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

56 lines
1.4 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")
2015-08-19 22:24:37 +02:00
all = container.querySelectorAll("a")
len = all.length - 1
while len >= 0
puts "li #{len}" + all.item(len).innerHTML + " lo"
len = len - 1
end
2015-08-18 23:08:12 +02:00
# red = -> (event) { container.style.backgroundColor = "red" }
2015-08-19 22:24:37 +02:00
red = -> (event) { puts container.innerHTML }
2015-08-18 23:08:12 +02:00
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
2015-08-19 22:24:37 +02:00
def class_header(id)
object = Virtual.machine.objects[id]
return "" unless object
clazz = object.class.name.split("::").last
"#{clazz}:#{id}"
end
2015-08-16 09:01:12 +02:00
def content(id)
object = Virtual.machine.objects[id]
fields = []
if object and ! object.is_a?(String)
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