如何从命令行直接调用 ruby 函数?
想象一下,我会有这个脚本test.rb:
class TestClass
def self.test_function(some_var)
puts "I got the following variable: #{some_var}"
end
end
如果从命令行 ( ruby test.rb
) 运行此脚本,则不会发生任何事情(如预期的那样)。
有没有类似的东西ruby test.rb TestClass.test_function('someTextString')
?我想得到以下输出:I got the following variable: someTextString
.