【发布时间】:2012-05-06 04:28:52
【问题描述】:
如何从命令行直接调用 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.
【问题讨论】:
标签: ruby command-line