rubyx-debugger/lib/ref_view.rb

49 lines
821 B
Ruby
Raw Normal View History

class RefView < ListView
2015-08-23 02:16:32 +02:00
def initialize name , value , z = nil
@name = name
@value = value
2015-08-23 02:16:32 +02:00
@z = z
super []
end
attr_reader :value
def value= val
@value = val
add_hover
end
def draw
@element = div("li") << div("a" , "#{@name} : #{marker(@value)}" )
add_hover
2015-08-23 02:16:32 +02:00
@element.style["z-index"] = @z if @z
@element
end
def add_hover
@element.on("hover"){ hover } if is_object?(@value)
end
def is_object?( id )
Virtual.machine.objects[id] != nil
end
def hover
puts "hovering #{@name}"
append ObjectView.new(@value)
@element.off("hover")
end
2015-08-23 02:16:32 +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}"
end
end