# 文件的当前目录
puts __FILE__
# 文件的当前行
puts __LINE__
#文件的当前目录
puts __dir__
puts __method__
def debug(param = "")
puts param
end
# 字符串拼接
puts ‘i am ‘ + ‘fish‘
# 字符串大小写转换
puts "我是Ruby, Hello World.".upcase
puts "我是Ruby, Hello World.".downcase
name = ‘haima‘
puts "i am #{name}"
puts "#{name + ",ok"}"
# 取数组里第一个元素里的某个key的值
resp = [{ :ip => "166.88.134.120", :port => "80", :title => "", :protocol => "http", :domain => "", :cert => "", :lastupdatetime => "2021-05-14 12:43:32" }, { :ip => "166.88.134.120", :port => "80", :title => "", :protocol => "http", :domain => "", :cert => "", :lastupdatetime => "2021-05-14 12:43:32" }]
puts resp.first[:lastupdatetime]
# 判断文件是否存在
flag = FileTest::exist?("/tmp/ip_result_file20210515-17252-1r26sn3.json")
puts flag == false
原文:https://www.cnblogs.com/haima/p/14771097.html