るりまサーチ

最速Rubyリファレンスマニュアル検索!
89件ヒット [1-89件を表示] (0.012秒)
トップページ > クエリ:pp[x] > クエリ:EVENTS[x]

別のキーワード

  1. pp pp
  2. pp seplist
  3. pp object_group
  4. pp singleline_pp
  5. pp comma_breakable

ライブラリ

クラス

キーワード

検索結果

Ripper::EVENTS -> [Symbol] (21101.0)

ripper の扱う全てのイベント ID (シンボル) のリストを返します。

...ripper の扱う全てのイベント ID (シンボル) のリストを返します。...

Ripper::PARSER_EVENTS -> [Symbol] (9101.0)

パーサイベントのイベント ID (シンボル) のリストを返します。

パーサイベントのイベント ID (シンボル) のリストを返します。

Ripper::SCANNER_EVENTS -> [Symbol] (9101.0)

スキャナイベントのイベント ID (シンボル) のリストを返します。

スキャナイベントのイベント ID (シンボル) のリストを返します。

Ripper.sexp(src, filename = '-', lineno = 1) -> object (3018.0)

Ruby プログラム str を解析して S 式のツリーにして返します。

...結果は、括弧の代わりに配列の要素として S 式のツリーを表現しています。

//emlist[例][ruby]{
require 'ripper'
require 'pp'

pp
Ripper.sexp("def m(a) nil end")
# => [:program,
# [[:def,
# [:@ident, "m", [1, 4]],
# [:paren, [:params, [[:@ident, "a", [1,...
...形式になります。

[:@イベント名, トークン, 位置情報(行、桁の配列)]

例:

[:@ident, "m", [1, 4]]

また、Ripper.sexp は Ripper.sexp_raw とは異なり、読みやすさのため
に stmts_add や stmts_new のような _add、_new で終わるパーサイベント...
...
省略します。_add で終わるパーサイベントはハンドラの引数が 0 個のものが
省略されます。詳しくは Ripper::PARSER_EVENTS を確認してください。

@see Ripper.sexp_raw...

Ripper::Filter#on_XXX(token, data) -> object (3012.0)

各種スキャナイベントを実行します。

...X」の部分を
Ripper::SCANNER_EVENTS にあるスキャナイベントに読み替えてください。

@param token 現在のトークンが指定されます。

@param data 前のイベントハンドラの戻り値です。最初のイベントの場合は
Ripper::Filter#parse...
...の引数になります。

オーバライドしなかった場合は on_default が実行されます。

このメソッドの戻り値は次のイベントハンドラの data 引数に渡されます。

@see Ripper::Filter#parse, Ripper::Filter#on_default, Ripper::SCANNER_EVENTS...

絞り込み条件を変える

Ripper.slice(src, pattern, n = 0) -> String | nil (3006.0)

Ruby プログラム src のうち、 パターン pattern の n 番目の括弧にマッチする文字列を取り出します。

...の括弧の中の文字列だけが必
要な時に指定します。省略すると 0 (pattern 全体)になります。

pattern は Ripper のイベント ID のリストを文字列で記述します。
また pattern には Ruby の正規表現と同じメタ文字も使えます。...
...単位ではなくトークン単位で動作します。

使用例

require 'ripper'
p Ripper.slice(%(<<HERE\nstring\#{nil}\nHERE),
"heredoc_beg .*? nl $(.*?) heredoc_end", 1)
# => "string\#{nil}\n"

イベント ID は Ripper::SCANNER_EVENTS で確認できます。...

Ripper::Filter (3006.0)

イベントドリブンスタイルで Ruby プログラムを加工するためのクラスです。

...必要なイベントに対応するメソッドを定義して使用し
ます。

=== 使用例

//emlist[][ruby]{
require 'ripper'
require 'cgi'

class Ruby2HTML < Ripper::Filter
def on_default(event, tok, f)
f << CGI.escapeHTML(tok)
end

def on_comment(tok, f)
f << %Q[<span class="...
...nd(tok, f)
f << %Q[#{CGI.escapeHTML(tok)}</span>]
end
end

Ruby2HTML.new(ARGF).parse('')
//}

Ruby プログラムを解析して、Ripper::SCANNER_EVENTS にあるスキャナ
イベントを実行します。イベントはプログラムに書いた順番で実行されます。

上記の...

NEWS for Ruby 3.0.0 (12.0)

NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...[[[1]], {}]

pr.call([1, {a: 1}])
# 2.7 => [[1], {:a=>1}] # and deprecation warning
# 3.0 => a=>1}, {}]
//}

* Arguments forwarding (`...`) now supports leading arguments.
16378

//emlist{
def method_missing(meth, ...)
send(:"do_#{meth}", ...)
end
//}

* Pattern matching (`case/in`) is...
...ERIMENTAL]
16828

//emlist{
case ["a", 1, "b", "c", 2, "d", "e", "f", 3]
in [*pre, String => x, String => y, *post]
p p
re #=> ["a", 1]
p x #=> "b"
p y #=> "c"
p p
ost #=> [2, "d", "e", "f", 3]
end
//}

* Endless method definition is added. [EXPERIMENTAL]
16746

//emlist{
def...
...IO#wait_readable, IO#wait_writable, IO#read, IO#write and other related methods (e.g. IO#puts, IO#gets) may invoke the scheduler hook `#io_wait(io, events, timeout)` in a non-blocking execution context. 16786
* Kernel
* Kernel#clone when called with the `freeze: false` keyword will call `#init...