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
Ruby/Rails: Convert Int to Time or Get Time from Integer
What Do the Different Brackets in Ruby Mean
How to Store Site-Wide Variables in Rails 4
Rbenv: Surviving Without Gemsets
What's the Difference Between Process.Fork and Process.Spawn in Ruby 1.9.2
How to Write a Ruby Command Line App That Supports Tab Completion
Find() with Nil When There Are No Records
How to Include Video in Jekyll Markdown Blog
How to Save Values into a Yaml File
Rails. How to Store Time of Day (For Schedule)
How to Call an Older Version of a Gem from the Commandline
Ruby on Rails Advanced JSON Serialization
How to Get Rspec-2 to Give the Full Trace Associated with a Test Failure
Rails Fixtures Not Loading with Rspec
Writing Over Previously Output Lines in the Command Prompt with Ruby
Heroku Rails 4 Could Not Connect to Server: Connection Refused
Rails: Plus Sign in Get-Request Replaced by Space
Rails How to Get Latitude and Longitude from String Address and Put It on Google Map