String(mes)
click to toggle source
def String(mes)
mes = super(mes)
if @encoding
mes.encode(@encoding, undef: :replace)
else
mes
end
end
find(file , paths = $:)
click to toggle source
def find(file , paths = $:)
dir = File.dirname(file)
dir = "" if dir == "."
base = File.basename(file)
if dir.start_with?('/')
return each_localized_path(dir, base).find{|full_path| File.readable? full_path}
else
return search_file(paths, dir, base)
end
end
gets(*rs)
click to toggle source
def gets(*rs)
String(super(*rs))
end
load(file, priv=nil)
click to toggle source
def load(file, priv=nil)
found = find(file)
if found
unless @@loaded.include?(found)
@@loaded << found
return real_load(found, priv)
end
else
raise LoadError, "No such file to load -- #{file}"
end
end
print(*opts)
click to toggle source
def print(*opts)
ary = opts.collect{|opt| String(opt)}
super(*ary)
end
printf(*opts)
click to toggle source
def printf(*opts)
s = format(*opts)
print s
end
puts(*opts)
click to toggle source
def puts(*opts)
ary = opts.collect{|opt| String(opt)}
super(*ary)
end
readline(*rs)
click to toggle source
def readline(*rs)
String(super(*rs))
end
require(file, priv = nil)
click to toggle source
def require(file, priv = nil)
rex = Regexp.new("lc/#{Regexp.quote(file)}\.(so|o|sl|rb)?")
return false if $".find{|f| f =~ rex}
case file
when /\.rb$/
begin
load(file, priv)
$".push file
return true
rescue LoadError
end
when /\.(so|o|sl)$/
return super
end
begin
load(f = file + ".rb")
$".push f
return true
rescue LoadError
return ruby_require(file)
end
end
toplevel_load(file, priv=nil)
click to toggle source