add Ruby demo

This commit is contained in:
Naoto Ono
2022-11-17 00:09:00 +09:00
parent 5668efba0a
commit 017cc54e17
4 changed files with 38 additions and 1 deletions

7
demos/ruby/README.md Normal file
View File

@@ -0,0 +1,7 @@
# Ruby Demos
To visualize Ruby objects, you need to install [debugvisualizer.gem](https://github.com/ono-max/debugvisualizer).
Install the gem by executing:
$ gem install debugvisualizer

View File

@@ -0,0 +1,18 @@
require 'debugvisualizer'
class Foo; end
DebugVisualizer.register Foo do |data|
{
id: "my_visualizer",
name: "My Visualizer",
data: {
kind: { text: true },
text: "Foo"
}
}
end
f = Foo.new
# visualize `f` here!
binding.break

View File

@@ -0,0 +1,12 @@
data = []
curVal = 0
100.times{
100.times{
delta = rand > 0.5 ? 1 : -1
data << curVal
curVal += delta
# visualize `data` here and press F5(or Continue button) over and over!
binding.break
}
}

View File

@@ -25,7 +25,7 @@ See [demos](../demos/) for demos. These languages and debuggers are verified to
- C++ using `cppdbg` debug adapter: [✅ Basic Support](../demos/cpp)
- Swift using `lldb` debug adapter: [✅ Basic Support](../demos/swift)
- Rust using `lldb` debug adapter: [✅ Basic Support](../demos/rust)
- Ruby using `rdbg` debug adapter: [✅ Basic Support]
- Ruby using `rdbg` debug adapter: [✅ Basic Support](../demos/ruby)
All other languages and debuggers might work too.
For languages with _Basic Support_, only JSON strings can be visualized - you must implement some logic that builds this JSON for your data structure!