Linux命令行::
[root@master1 ~]# irb
irb(main):001:0> puts "hello,world!"
hello,world!
=> nil
irb(main):002:0>
使用Dir.pwd得到当前文件夹
[root@master1 ruby]# irb
irb(main):001:0> Dir.pwd
=> "/m8/ruby"
irb(main):002:0> path = Dir.pwd + "/testfile.txt"
=> "/m8/ruby/testfile.txt"
===============================================================
vim test1.rb
puts "hello world!"
def hello(name)
puts "hello #{name}!"
end
hello('centos7')
运行输出如下:
[root@master1 ruby]# ruby test1.rb
hello world!
hello centos7!
ruby文档查看
RDoc
命令行启动:
ri --serve
然后浏览器访问:
http://172.18.1.217:8214/
ri --help