Reputation: 6144
I want to wrap the puts
method with new lines before and after.
I searched the docs and didn't find where this function comes from. Ideas?
Upvotes: 1
Views: 206
Reputation: 71
You could override the puts
method like so:
def puts(object)
super('')
super(object)
super('')
end
If you really wanted to you could monkey patch the method like below. Although your changes would probably have unintended effects.
module Kernel
def puts(object)
# code
end
end
You can read about monkey patching in the Ruby docs here.
Upvotes: 2