Created
September 18, 2012 17:37
-
-
Save numinit/3744525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
def std | |
@@std ||= Module.new do | |
def ios | |
Module.new do | |
def ios | |
@@ios ||= Class.new do | |
def initialize stream | |
@stream = stream | |
end | |
end | |
end | |
end | |
end | |
def istream | |
Module.new do | |
include std::ios | |
def istream | |
@@istream ||= Class.new(std::ios) do | |
def initialize stream | |
super stream | |
end | |
def get | |
@stream.read | |
end | |
end | |
end | |
end | |
end | |
def ostream | |
Module.new do | |
include std::ios | |
def ostream | |
@@ostream ||= Class.new(std::ios) do | |
def initialize stream | |
super stream | |
end | |
def << rhs | |
@stream.write rhs | |
self | |
end | |
end | |
end | |
end | |
end | |
def iostream | |
Module.new do | |
include std::istream | |
include std::ostream | |
def cout | |
@@cout ||= std::ostream.new(STDOUT) | |
end | |
def cerr | |
@@cerr ||= std::ostream.new(STDERR) | |
end | |
def cin | |
@@cin ||= std::istream.new(STDIN) | |
end | |
def endl | |
"\n" | |
end | |
end | |
end | |
end | |
end | |
end | |
include std |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What have you done?.. :-(