Skip to content

Instantly share code, notes, and snippets.

@qickstarter
Created November 28, 2012 10:32
Show Gist options
  • Select an option

  • Save qickstarter/4160371 to your computer and use it in GitHub Desktop.

Select an option

Save qickstarter/4160371 to your computer and use it in GitHub Desktop.
# coding: utf-8
class Object
def pinch2chance
gsub!('ピンチ', 'チャンス') if respond_to? :gsub
self
end
end
module Kernel
alias_method :old_puts, :puts
# putsをフック
def puts(*args)
args.map! { |obj| obj.pinch2chance }
old_puts(args)
end
end
class String
alias_method :old_inspect, :inspect
# pで呼び出されるinspectをフック
def inspect
pinch2chance
old_inspect
end
end
p "ピンチでしかない"
puts "今がピンチ"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment