るりまサーチ

最速Rubyリファレンスマニュアル検索!
34件ヒット [1-34件を表示] (0.046秒)
トップページ > クエリ:String[x] > クエリ:body[x] > クエリ:param[x] > ライブラリ:ビルトイン[x]

別のキーワード

  1. string []=
  2. string slice
  3. string []
  4. string slice!
  5. string gsub

クラス

モジュール

キーワード

検索結果

RubyVM::InstructionSequence.disasm(body) -> String (234.0)

引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。

...引数 body で指定したオブジェクトから作成した
RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字
列に変換して返します。

@param body Proc、Method オブジェクトを指定します。

例1:Proc オブジェクトを指定した場合...
...( 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 (234.0)

引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。

...引数 body で指定したオブジェクトから作成した
RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字
列に変換して返します。

@param body Proc、Method オブジェクトを指定します。

例1:Proc オブジェクトを指定した場合...
...( 1)
0002 trace 1 ( 2)
0004 putself
0005 putstring "hello, world"
0007 send :puts, 1, nil, 8, <ic:0>
0013 trace 16 (...

RubyVM::AbstractSyntaxTree.parse(string) -> RubyVM::AbstractSyntaxTree::Node (152.0)

文字列を抽象構文木にパースし、その木の根ノードを返します。

...を返します。

@param string パースする対象の Ruby のコードを文字列で指定します。
@param keep_script_lines true を指定すると、 Node#script_lines でノードと関連づけられたソースコードのテキストを取得できます。
@param keep_tokens true...
...、 Node#token が利用できます。
@param error_tolerant true を指定すると、構文エラーが発生した際にエラー箇所を type が :ERROR であるようなノードに置き換えてツリーを生成します。
@raise SyntaxError string が Ruby のコードとして正しく...
...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:...

RubyVM::AbstractSyntaxTree.parse(string, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node (152.0)

文字列を抽象構文木にパースし、その木の根ノードを返します。

...を返します。

@param string パースする対象の Ruby のコードを文字列で指定します。
@param keep_script_lines true を指定すると、 Node#script_lines でノードと関連づけられたソースコードのテキストを取得できます。
@param keep_tokens true...
...、 Node#token が利用できます。
@param error_tolerant true を指定すると、構文エラーが発生した際にエラー箇所を type が :ERROR であるようなノードに置き換えてツリーを生成します。
@raise SyntaxError string が Ruby のコードとして正しく...
...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:...

RubyVM::AbstractSyntaxTree.parse(string) -> RubyVM::AbstractSyntaxTree::Node (127.0)

文字列を抽象構文木にパースし、その木の根ノードを返します。

...文字列を抽象構文木にパースし、その木の根ノードを返します。

@param string パースする対象の Ruby のコードを文字列で指定します。
@raise SyntaxError string が Ruby のコードとして正しくない場合に発生します。

//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))))
//}...

絞り込み条件を変える

Data.define(*args) -> Class (50.0)

Data クラスに新しいサブクラスを作って、それを返します。

...用できます。

//emlist[例][ruby]{
class HTTPFetcher
Response = Data.define(:body)
NotFound = Data.define

def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
NotFound.new
end
end
end

def...
...fetcher.get(url)
in HTTPFetcher::Response(body)
body

in HTTPFetcher::NotFound
:NotFound
end
end

p fetch("http://example.com/") # => "Current time is 2023-01-10 10:00:53 +0900"
p fetch("http://example.com/404") # => :NotFound
//}

@param args 値オブジェクトのクラスを...
...定義するための可変長引数。Symbol または String を指定します。

@return Data のサブクラスを返します。

@raise TypeError 引数に Symbol, String (String に暗黙の型変換が行われるオブジェクトを含む) 以外を指定した場合に発生します。...

Data.define(*args) {|subclass| block } -> Class (50.0)

Data クラスに新しいサブクラスを作って、それを返します。

...用できます。

//emlist[例][ruby]{
class HTTPFetcher
Response = Data.define(:body)
NotFound = Data.define

def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
NotFound.new
end
end
end

def...
...fetcher.get(url)
in HTTPFetcher::Response(body)
body

in HTTPFetcher::NotFound
:NotFound
end
end

p fetch("http://example.com/") # => "Current time is 2023-01-10 10:00:53 +0900"
p fetch("http://example.com/404") # => :NotFound
//}

@param args 値オブジェクトのクラスを...
...定義するための可変長引数。Symbol または String を指定します。

@return Data のサブクラスを返します。

@raise TypeError 引数に Symbol, String (String に暗黙の型変換が行われるオブジェクトを含む) 以外を指定した場合に発生します。...