ライブラリ
- ビルトイン (84)
-
irb
/ context (12) -
irb
/ extend-command (12) - json (12)
クラス
-
IRB
:: Context (12) - Regexp (24)
-
RubyVM
:: InstructionSequence (24) - TracePoint (12)
オブジェクト
- main (24)
キーワード
-
define
_ method (24) - disasm (12)
- disassemble (12)
-
irb
_ original _ method _ name (12) -
json
_ create (12) -
last
_ match (24) - new (24)
検索結果
先頭5件
- IRB
:: ExtendCommandBundle . irb _ original _ method _ name(method _ name) -> String - main
. define _ method(name , method) -> Symbol - main
. define _ method(name) { . . . } -> Symbol - JSON
:: Generator :: GeneratorMethods :: String :: Extend . json _ create(hash) -> String - IRB
:: Context . new(irb , workspace = nil , input _ method = nil , output _ method = nil) -> IRB :: Context
-
IRB
:: ExtendCommandBundle . irb _ original _ method _ name(method _ name) -> String (6332.0) -
method_name で指定したメソッドの irb 中でのエイリアスを返します。ライブ ラリ内部で使用します。
...
method_name で指定したメソッドの irb 中でのエイリアスを返します。ライブ
ラリ内部で使用します。
@param method_name メソッド名を Symbol か文字列で指定します。
@see IRB::ExtendCommandBundle#install_alias_method... -
main
. define _ method(name , method) -> Symbol (6234.0) -
インスタンスメソッド name を Object に定義します。
...す。
@param name String または Symbol を指定します。
@param method Proc、Method あるいは UnboundMethod の
いずれかのインスタンスを指定します。
@return メソッド名を表す Symbol を返します。
@raise TypeError method に同じクラス......、サブクラス以外のメソッドを指定し
た場合に発生します。
@see Module#define_method... -
main
. define _ method(name) { . . . } -> Symbol (6134.0) -
インスタンスメソッド name を Object に定義します。
...す。
@param name String または Symbol を指定します。
@param method Proc、Method あるいは UnboundMethod の
いずれかのインスタンスを指定します。
@return メソッド名を表す Symbol を返します。
@raise TypeError method に同じクラス......、サブクラス以外のメソッドを指定し
た場合に発生します。
@see Module#define_method... -
JSON
:: Generator :: GeneratorMethods :: String :: Extend . json _ create(hash) -> String (6108.0) -
JSON のオブジェクトから Ruby の文字列を生成して返します。
...のオブジェクトから Ruby の文字列を生成して返します。
@param hash キーとして "raw" という文字列を持ち、その値として数値の配列を持つハッシュを指定します。
require 'json'
String.json_create({"raw" => [0x41, 0x42, 0x43]}) # => "ABC"... -
IRB
:: Context . new(irb , workspace = nil , input _ method = nil , output _ method = nil) -> IRB :: Context (221.0) -
自身を初期化します。
...た場合は新しく作成されます。
@param input_method String、IRB::InputMethod のサブクラスの
オブジェクト、nil のいずれかを指定します。
@param output_method IRB::OutputMethod のサブクラスのオブジェクト......を指定します。省略した場合は
IRB::StdioOutputMethod オブジェクトが新しく
作成されます。... -
RubyVM
:: InstructionSequence . disasm(body) -> String (133.0) -
引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。
...成した
RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字
列に変換して返します。
@param body Proc、Method オブジェクトを指定します。
例1:Proc オブジェクトを指定した場合
# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts Rub......num, 0
0012 leave
例2:Method オブジェクトを指定した場合
# /tmp/method.rb
def hello
puts "hello, world"
end
puts RubyVM::InstructionSequence.disasm(method(:hello))
出力:
== disasm: <RubyVM::InstructionSequence:hello@/tmp/method.rb>============
0000 trace......( 1)
0002 trace 1 ( 2)
0004 putself
0005 putstring "hello, world"
0007 send :puts, 1, nil, 8, <ic:0>
0013 trace 16 (... -
RubyVM
:: InstructionSequence . disassemble(body) -> String (133.0) -
引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。
...成した
RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字
列に変換して返します。
@param body Proc、Method オブジェクトを指定します。
例1:Proc オブジェクトを指定した場合
# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts Rub......num, 0
0012 leave
例2:Method オブジェクトを指定した場合
# /tmp/method.rb
def hello
puts "hello, world"
end
puts RubyVM::InstructionSequence.disasm(method(:hello))
出力:
== disasm: <RubyVM::InstructionSequence:hello@/tmp/method.rb>============
0000 trace......( 1)
0002 trace 1 ( 2)
0004 putself
0005 putstring "hello, world"
0007 send :puts, 1, nil, 8, <ic:0>
0013 trace 16 (... -
Regexp
. last _ match(nth) -> String | nil (108.0) -
整数 nth が 0 の場合、マッチした文字列を返します ($&)。それ以外では、nth 番目の括弧にマッチ した部分文字列を返します($1,$2,...)。 対応する括弧がない場合やマッチしなかった場合には nil を返し ます。
...例外 NoMethodError が発生します。
対して、last_match(1) は nil を返します。
//emlist[例][ruby]{
str = "This is Regexp"
/That is Regexp/ =~ str
p Regexp.last_match # => nil
begin
p Regexp.last_match[1] # 例外が発生する
rescue
puts $! # => undefined method `[]' for ni... -
TracePoint
. new(*events) {|obj| . . . } -> TracePoint (13.0) -
新しい TracePoint オブジェクトを作成して返します。トレースを有効 にするには TracePoint#enable を実行してください。
...してください。
//emlist[例:irb で実行した場合][ruby]{
trace = TracePoint.new(:call) do |tp|
p [tp.lineno, tp.defined_class, tp.method_id, tp.event]
end
# => #<TracePoint:0x007f17372cdb20>
trace.enable
# => false
puts "Hello, TracePoint!"
# ...
# [69, IRB::Notifier::AbstractNoti......るには TracePoint#disable を実行してください。
//emlist[][ruby]{
trace.disable
//}
@param events トレースするイベントを String か Symbol で任
意の数指定します。
: :line
式の評価。
: :class
クラス定義、特異クラス定義、モ...