static public Method

RubyToken.def_token(token_n, super_token = Token, reading = nil, *opts)

There's no documentation for this item.

Source Code

# File irb/ruby-token.rb, line 250
def RubyToken.def_token(token_n, super_token = Token, reading = nil, *opts)
  token_n = token_n.id2name if token_n.kind_of?(Symbol)
  if RubyToken.const_defined?(token_n)
    IRB.fail AlreadyDefinedToken, token_n
  end
  token_c = eval("class #{token_n} < #{super_token}; end; #{token_n}")

  if reading
    if TkReading2Token[reading]
      IRB.fail TkReading2TokenDuplicateError, token_n, reading
    end
    if opts.empty?
      TkReading2Token[reading] = [token_c]
    else
      TkReading2Token[reading] = [token_c].concat(opts)
    end
  end
  TkSymbol2Token[token_n.intern] = token_c
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.