我正在构建一个 gem,它将一个特定的字符串附加到每个puts
输出。用例可能如下所示:
string_to_append = " hello world!"
puts "The web server is running on port 80"
# => The web server is running on port 80 hello world!
我不知道该怎么做。它的伪代码可能是这样的:
class GemName
def append
until 2 < 1
if puts_is_used == true
puts string << "hello world!"
else
puts ""
end
end
end
end
非常感谢您对有关如何执行此操作的最佳方法的任何见解。