0
我想在特定的heredoc字符串後追加一個heredoc字符串,如果文件沒有包含它的話。如果文件不包含該heredoc字符串,在特定的heredoc字符串之後追加heredoc字符串?
例如,
這裏有2個文件:
# file1
Description:
I am a coder
Username: user1
Password: password1
# file2
Description:
I am a coder
Username: user2
Password: password2
Address:
Email: [email protected]
Street: user street 19 A
我想補充:
Address:
Email: [email protected]
Street: user street 19 A
如果文件不包含它已經和後:
Description:
I am a coder
所以在上面的文件只會被添加到第一個文件中。然後該文件將如下所示:
# file1
Description:
I am a coder
Address:
Email: [email protected]
Street: user street 19 A
Username: user1
Password: password1
我怎麼能在Ruby中做到這一點?