rubyx-debugger/app/source_view.rb

32 lines
541 B
Ruby
Raw Normal View History

2015-07-22 15:22:54 +02:00
class SourceView
include React::Component
2015-07-27 11:09:35 +02:00
required_param :source
2015-07-22 15:22:54 +02:00
2015-07-27 11:09:35 +02:00
define_state :sources => []
before_update do
text = source_text(source)
return if sources.last == text
sources << text
sources.shift if sources.length > 5
end
2015-07-22 15:22:54 +02:00
def render
div.row do
"Virtual Machine Instruction".br
2015-07-27 11:09:35 +02:00
sources.each do |s|
s.br
end
2015-07-22 15:22:54 +02:00
end
end
2015-07-27 11:09:35 +02:00
def source_text
if source.is_a? Virtual::Instruction
return source.class.name
else
return "Method: #{source.name}"
end
end
2015-07-22 15:22:54 +02:00
end