In Files

  • irb/locale.rb

IRB::Locale

Attributes

lang[R]

Public Class Methods

new(locale = nil) click to toggle source
 
               # File irb/locale.rb, line 22
def initialize(locale = nil)
  @lang = locale || ENV["IRB_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C" 
end
            

Public Instance Methods

String(mes) click to toggle source
 
               # File irb/locale.rb, line 40
def String(mes)
  mes = super(mes)
  case @lang
  when /^ja/
    mes = Kconv::kconv(mes, lc2kconv(@lang))
  else
    mes
  end
  mes
end
            
find(file , paths = $:) click to toggle source
 
               # File irb/locale.rb, line 139
def find(file , paths = $:)
  dir = File.dirname(file)
  dir = "" if dir == "."
  base = File.basename(file)
  if dir[0] == ?/ #/
      return lc_path = search_file(dir, base)
  else
    for path in $:
      if lc_path = search_file(path + "/" + dir, base)
        return lc_path
      end
    end
  end
  nil
end
            
format(*opts) click to toggle source
 
               # File irb/locale.rb, line 51
def format(*opts)
  String(super(*opts))
end
            
gets(*rs) click to toggle source
 
               # File irb/locale.rb, line 55
def gets(*rs)
  String(super(*rs))
end
            
load(file, priv=nil) click to toggle source
 
               # File irb/locale.rb, line 105
def load(file, priv=nil)
  dir = File.dirname(file)
  dir = "" if dir == "."
  base = File.basename(file)

  if /^ja(_JP)?$/ =~ @lang
    back, @lang = @lang, "C"
  end
  begin
    if dir[0] == ?/ #/
      lc_path = search_file(dir, base)
      return real_load(lc_path, priv) if lc_path
    end
    
    for path in $:
      lc_path = search_file(path + "/" + dir, base)
      return real_load(lc_path, priv) if lc_path
    end
  ensure
    @lang = back if back
  end
  raise LoadError, "No such file to load -- #{file}"
end
            
Also aliased as: toplevel_load
printf(*opts) click to toggle source
 
               # File irb/locale.rb, line 68
def printf(*opts)
  s = format(*opts)
  print s
end
            
puts(*opts) click to toggle source
 
               # File irb/locale.rb, line 73
def puts(*opts)
  ary = opts.collect{|opt| String(opt)}
  super(*ary)
end
            
readline(*rs) click to toggle source
 
               # File irb/locale.rb, line 59
def readline(*rs)
  String(super(*rs))
end
            
require(file, priv = nil) click to toggle source
 
               # File irb/locale.rb, line 78
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
Alias for: load

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus