What Command Opens Ruby's Repl

What command opens Ruby's REPL?

Use the irb (Interactive Ruby Shell) command.

https://en.wikipedia.org/wiki/Interactive_Ruby_Shell

The command ruby does nothing on my Mac

Ruby command itself will just behave the way you said, either provide it with script file or use the -e option:

ruby -e ' puts "hello world" '

However I suspect that you want the IRB(interactive ruby). Run irb in your shell.

method-call in REPL returns weirdly nothing

@florian You picked the wrong configuration.

You should refer to Web::Assets.configuration.prefix, instead of Web::Application.configuration.assets.

The latter is a proxy that "accumulates" all the commands and then apply them to the target configuration.

Creating interactive ruby console application

What you want is a REPL – Read → Evaluate → Print Loop.

IRB, for example, implements a REPL for the Ruby language.

Here's a very simple implementation of your application's REPL:

loop do
Application::Console.prompt.display
input = gets.chomp
command, *params = input.split /\s/

case command
when /\Ahelp\z/i
puts Application::Console.help_text
when /\Aopen\z/i
Application::Task.open params.first
when /\Ado\z/i
Application::Action.perform *params
else puts 'Invalid command'
end
end

\A and \z match the start of the string and the end of the string, respectively.



Related Topics



Leave a reply



Submit