2015-08-20 19:40:47 +02:00
|
|
|
class ClassView < ElementView
|
2015-08-20 00:53:20 +02:00
|
|
|
|
2015-08-20 19:40:47 +02:00
|
|
|
def initialize interpreter
|
|
|
|
@interpreter = interpreter
|
|
|
|
@classes = []
|
2015-08-20 00:53:20 +02:00
|
|
|
Virtual.machine.space.classes.each do |name , claz|
|
|
|
|
next if [:Kernel,:Module,:MetaClass,:BinaryCode].index name
|
2015-08-20 19:40:47 +02:00
|
|
|
@classes << name
|
2015-08-20 00:53:20 +02:00
|
|
|
end
|
2015-08-20 19:40:47 +02:00
|
|
|
@classes.sort!
|
2015-08-20 00:53:20 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def variables(clas_model)
|
|
|
|
layout = Virtual.machine.space.get_class_by_name(clas_model._name).object_layout
|
|
|
|
vars = []
|
|
|
|
layout.object_instance_names.each do |name|
|
|
|
|
vars.push name
|
|
|
|
end
|
|
|
|
vars
|
|
|
|
end
|
2015-08-20 14:48:45 +02:00
|
|
|
|
|
|
|
def draw
|
2015-08-20 19:40:47 +02:00
|
|
|
DOM do |dom|
|
|
|
|
dom.div.classes do
|
|
|
|
dom.h4 {"Classes"}
|
|
|
|
dom.ul.nav! do
|
|
|
|
@classes.each do |cl|
|
|
|
|
dom.li do
|
|
|
|
dom.a { cl }
|
|
|
|
end
|
|
|
|
end
|
2015-08-20 14:48:45 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-08-20 19:40:47 +02:00
|
|
|
# <a href="#">{{ clas._name }}</a>
|
|
|
|
# {{ unless variables(clas).empty? }}
|
|
|
|
# <ul>
|
|
|
|
# {{variables(clas).each do |var| }}
|
|
|
|
# <li>
|
|
|
|
# <a href="#">{{var}}</a>
|
|
|
|
# </li>
|
|
|
|
# {{ end }}
|
|
|
|
# </ul>
|
2015-08-20 14:48:45 +02:00
|
|
|
|
2015-08-20 00:53:20 +02:00
|
|
|
end
|