種類
- モジュール関数 (33)
- インスタンスメソッド (32)
- 特異メソッド (16)
ライブラリ
- ビルトイン (81)
クラス
- Object (26)
-
RubyVM
:: AbstractSyntaxTree :: Node (6)
モジュール
- Kernel (33)
-
RubyVM
:: AbstractSyntaxTree (16)
キーワード
- caller (33)
- children (6)
-
parse
_ file (8) - then (12)
-
yield
_ self (14)
検索結果
先頭5件
- RubyVM
:: AbstractSyntaxTree . parse(string) -> RubyVM :: AbstractSyntaxTree :: Node - RubyVM
:: AbstractSyntaxTree . parse(string , keep _ script _ lines: false , error _ tolerant: false , keep _ tokens: false) -> RubyVM :: AbstractSyntaxTree :: Node - RubyVM
:: AbstractSyntaxTree . parse(string) -> RubyVM :: AbstractSyntaxTree :: Node - RubyVM
:: AbstractSyntaxTree . parse _ file(pathname) -> RubyVM :: AbstractSyntaxTree :: Node - RubyVM
:: AbstractSyntaxTree . parse _ file(pathname , keep _ script _ lines: false , error _ tolerant: false , keep _ tokens: false) -> RubyVM :: AbstractSyntaxTree :: Node
-
RubyVM
:: AbstractSyntaxTree . parse(string) -> RubyVM :: AbstractSyntaxTree :: Node (26132.0) -
文字列を抽象構文木にパースし、その木の根ノードを返します。
...uby]{
pp RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# => (SCOPE@1:0-1:9
# tbl: [:x]
# args: nil
# body:
# (LASGN@1:0-1:9 :x
# (OPCALL@1:4-1:9 (LIT@1:4-1:5 1) :+ (LIST@1:8-1:9 (LIT@1:8-1:9 2) nil))))
pp RubyVM::AbstractSyntaxTree.parse("x = 1; p(x; y=2", error_tolerant:......true)
# => (SCOPE@1:0-1:15
# tbl: [:x, :y]
# args: nil
# body: (BLOCK@1:0-1:15 (LASGN@1:0-1:5 :x (LIT@1:4-1:5 1)) (ERROR@1:7-1:11) (LASGN@1:12-1:15 :y (LIT@1:14-1:15 2))))
//}... -
RubyVM
:: AbstractSyntaxTree . parse(string , keep _ script _ lines: false , error _ tolerant: false , keep _ tokens: false) -> RubyVM :: AbstractSyntaxTree :: Node (26132.0) -
文字列を抽象構文木にパースし、その木の根ノードを返します。
...uby]{
pp RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# => (SCOPE@1:0-1:9
# tbl: [:x]
# args: nil
# body:
# (LASGN@1:0-1:9 :x
# (OPCALL@1:4-1:9 (LIT@1:4-1:5 1) :+ (LIST@1:8-1:9 (LIT@1:8-1:9 2) nil))))
pp RubyVM::AbstractSyntaxTree.parse("x = 1; p(x; y=2", error_tolerant:......true)
# => (SCOPE@1:0-1:15
# tbl: [:x, :y]
# args: nil
# body: (BLOCK@1:0-1:15 (LASGN@1:0-1:5 :x (LIT@1:4-1:5 1)) (ERROR@1:7-1:11) (LASGN@1:12-1:15 :y (LIT@1:14-1:15 2))))
//}... -
RubyVM
:: AbstractSyntaxTree . parse(string) -> RubyVM :: AbstractSyntaxTree :: Node (26119.0) -
文字列を抽象構文木にパースし、その木の根ノードを返します。
...として正しくない場合に発生します。
//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# => (SCOPE@1:0-1:9
# tbl: [:x]
# args: nil
# body:
# (LASGN@1:0-1:9 :x
# (OPCALL@1:4-1:9 (LIT@1:4-1:5 1) :+ (LIST@1:8-1:9 (LIT@1:8-1:9 2) nil))))
//}... -
RubyVM
:: AbstractSyntaxTree . parse _ file(pathname) -> RubyVM :: AbstractSyntaxTree :: Node (14132.0) -
pathname のファイルを読み込み、その内容を抽象構文木にパースし、その木の根ノードを返します。
...tractSyntaxTree.parse_file(__FILE__)
# => (SCOPE@1:0-1:50
# tbl: []
# args: nil
# body:
# (FCALL@1:0-1:50 :pp
# (LIST@1:3-1:50
# (CALL@1:3-1:50
# (COLON2@1:3-1:29 (CONST@1:3-1:9 :RubyVM) :AbstractSyntaxTree)
# :parse_file (LIST@1:4......1-1:49 (STR@1:41-1:49 "") nil)) nil)))
//}... -
RubyVM
:: AbstractSyntaxTree . parse _ file(pathname , keep _ script _ lines: false , error _ tolerant: false , keep _ tokens: false) -> RubyVM :: AbstractSyntaxTree :: Node (14132.0) -
pathname のファイルを読み込み、その内容を抽象構文木にパースし、その木の根ノードを返します。
...tractSyntaxTree.parse_file(__FILE__)
# => (SCOPE@1:0-1:50
# tbl: []
# args: nil
# body:
# (FCALL@1:0-1:50 :pp
# (LIST@1:3-1:50
# (CALL@1:3-1:50
# (COLON2@1:3-1:29 (CONST@1:3-1:9 :RubyVM) :AbstractSyntaxTree)
# :parse_file (LIST@1:4......1-1:49 (STR@1:41-1:49 "") nil)) nil)))
//}... -
RubyVM
:: AbstractSyntaxTree . parse _ file(pathname) -> RubyVM :: AbstractSyntaxTree :: Node (14131.0) -
pathname のファイルを読み込み、その内容を抽象構文木にパースし、その木の根ノードを返します。
...tractSyntaxTree.parse_file(__FILE__)
# => (SCOPE@1:0-1:50
# tbl: []
# args: nil
# body:
# (FCALL@1:0-1:50 :pp
# (LIST@1:3-1:50
# (CALL@1:3-1:50
# (COLON2@1:3-1:29 (CONST@1:3-1:9 :RubyVM) :AbstractSyntaxTree)
# :parse_file (LIST@1:4......1-1:49 (STR@1:41-1:49 "") nil)) nil)))
//}... -
Kernel
. # caller(range) -> [String] | nil (8151.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を返します。
@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得するス......10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}
以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1......to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(caller.first)
end
def bar
foo
p parse_caller(caller.first)
end
bar
p parse_caller(caller.first)
#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真の場合に役に立つ debug 関数... -
Kernel
. # caller(start = 1) -> [String] | nil (8151.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を返します。
@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得するス......10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}
以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1......to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(caller.first)
end
def bar
foo
p parse_caller(caller.first)
end
bar
p parse_caller(caller.first)
#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真の場合に役に立つ debug 関数... -
Kernel
. # caller(start , length) -> [String] | nil (8151.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を返します。
@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得するス......10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}
以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1......to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(caller.first)
end
def bar
foo
p parse_caller(caller.first)
end
bar
p parse_caller(caller.first)
#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}
以下は、$DEBUG が真の場合に役に立つ debug 関数... -
RubyVM
:: AbstractSyntaxTree :: Node # children -> Array (8018.0) -
self の子ノードを配列で返します。
...type によって異なります。
戻り値は、ほかの RubyVM::AbstractSyntaxTree::Node のインスタンスや nil を含みます。
//emlist[][ruby]{
node = RubyVM::AbstractSyntaxTree.parse('1 + 2')
p node.children
# => [[], nil, #<RubyVM::AbstractSyntaxTree::Node:OPCALL@1:0-1:5>]
//}... -
Object
# then -> Enumerator (8012.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...ライン][ruby]{
require 'open-uri'
require 'json'
construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使......えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# then {|x| . . . } -> object (8012.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...ライン][ruby]{
require 'open-uri'
require 'json'
construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使......えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# yield _ self -> Enumerator (8012.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...ライン][ruby]{
require 'open-uri'
require 'json'
construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使......えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap... -
Object
# yield _ self {|x| . . . } -> object (8012.0) -
self を引数としてブロックを評価し、ブロックの結果を返します。
...ライン][ruby]{
require 'open-uri'
require 'json'
construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}
ブロックなしで呼び出されたときは Enumerator を返します。
例えば条件によって値を捨てるのに使......えます。
//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}
@see Object#tap...