2015-08-20 20:03:00 +02:00
|
|
|
class StatusView < ElementView
|
|
|
|
|
2015-08-22 01:06:48 +02:00
|
|
|
def initialize interpreter
|
|
|
|
@interpreter = interpreter
|
|
|
|
end
|
2015-08-20 20:03:00 +02:00
|
|
|
|
2015-08-22 01:06:48 +02:00
|
|
|
def draw
|
2015-08-22 01:37:15 +02:00
|
|
|
@element = div(".status_view") <<
|
2015-08-24 01:44:50 +02:00
|
|
|
div("h4" , "Interpreter" ) <<
|
2015-08-22 01:06:48 +02:00
|
|
|
div("button.act" , "Next") <<
|
|
|
|
div( "br") <<
|
2015-08-24 01:44:50 +02:00
|
|
|
div("span.clock" , clock_text) <<
|
|
|
|
div( "br") <<
|
2015-08-22 01:06:48 +02:00
|
|
|
div("span.state" , state_text) <<
|
|
|
|
div( "br") <<
|
|
|
|
div( "span.link" , link_text) <<
|
|
|
|
div( "br" , "Stdout") <<
|
|
|
|
div("span.stdout")
|
|
|
|
# set up event handler
|
2015-08-22 01:59:29 +02:00
|
|
|
@element.at_css(".act").on("click") { self.update }
|
2015-08-22 01:06:48 +02:00
|
|
|
return @element
|
|
|
|
end
|
2015-08-20 20:03:00 +02:00
|
|
|
|
2015-08-22 01:06:48 +02:00
|
|
|
def update
|
2015-08-22 01:59:29 +02:00
|
|
|
@interpreter.tick
|
|
|
|
@element.at_css(".clock").text = clock_text
|
|
|
|
@element.at_css(".link").text = link_text
|
|
|
|
@element.at_css(".stdout").text = @interpreter.stdout
|
2015-08-22 01:06:48 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def link_text
|
|
|
|
"Link #{@interpreter.link}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def state_text
|
|
|
|
"State #{@interpreter.state}"
|
|
|
|
end
|
|
|
|
|
2015-08-22 01:59:29 +02:00
|
|
|
def clock_text
|
2015-08-22 01:06:48 +02:00
|
|
|
"Instruction #{@interpreter.clock}"
|
|
|
|
end
|
|
|
|
end
|