我有一个方法,例如:
def change(string)
return string
end
将在传入的字符串流上多次调用方法更改,例如:
1367 INFO sslsniff : Certificate Ready: test.neocal.info
1367 DEBUG sslsniff : New source 172.16.23.121:47864 <-> destination 54.241.163.174:443
1367 INFO sslsniff : Certificate Ready: test.neocal.info
1367 DEBUG sslsniff : New source 172.16.23.121:47882 <-> destination 54.241.163.174:443
1367 DEBUG sslsniff : New source 172.16.23.121:47883 <-> destination 54.241.163.174:443
1367 DEBUG sslsniff : New source 172.16.23.121:47884 <-> destination 54.241.163.174:443
我想进行更改,以便每当读入包含Certificate Ready: test.neocal.info的行时,我想对其进行更改以使其返回整行,但它将“ test.neocal.info ”替换为字符串' voidparse '。
我的尝试是:
def change(string)
arr = string.split(':')
if arr[1] == " Certificate Ready"
arr[2] == "nullvoid"
end
# it's this part i'm stuck--how can i rebuild the string with the modified array?
return string
end