Skip to content

Instantly share code, notes, and snippets.

@atton
Last active December 17, 2015 05:59
Show Gist options
  • Save atton/5562192 to your computer and use it in GitHub Desktop.
Save atton/5562192 to your computer and use it in GitHub Desktop.
flush するスタイルに変更
#!/usr/bin/env ruby
# Okinawarb.new.H.e.l.l.o.comma.space.w.o.r.l.d!.flush("\n")
# => output 'Hello, wrold!'
class String
CharTable = {comma:',', space:' '}
def flush str
print self, str
end
def method_missing name, *args
return self + (CharTable[name] || name).to_s
end
end
class Okinawarb < String
end
Okinawarb.new.H.e.l.l.o.comma.space.w.o.r.l.d!.flush("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment