How to input a string in IRuby + Jupyter?

205 views Asked by At

I'm using iruby on Jupyter. In python kernel (ipython), one can input a string from notebook by calling input() function.

Is it possible to achieve the same thing in iruby?

2

There are 2 answers

0
kojix2 On BEST ANSWER

If you use Jupyter Notebook, try IRuby.input

https://github.com/SciRuby/iruby/tree/master/lib/iruby/input

But this input box may not work in Jupyter Lab.

0
Gerhard On

Simple text input is done with IRuby.input:

name = IRuby.input 'Enter your name'

Multiple fields of input is done with IRuby.form:

result = IRuby.form do 
  input :username
  button
end

It returns a Hash with the input field names as labels.