別のキーワード
ライブラリ
- ビルトイン (33)
モジュール
- Kernel (33)
キーワード
-
NEWS for Ruby 2
. 3 . 0 (9) -
NEWS for Ruby 3
. 0 . 0 (4) -
NEWS for Ruby 3
. 1 . 0 (3) - caller (33)
- irb (11)
- rdoc (11)
- 制御構造 (11)
検索結果
先頭5件
-
debug (38018.0)
-
Ruby デバッガです。Ruby スクリプトのソースコードデバッグに使用します。
...したインタフェース rubydb3x.el が
https://github.com/ruby/elisp にあるので、活用してください。
=== 使い方
$ ruby -rdebug foo.rb
または、Emacs から
M-x load-library rubydb3x.el
M-x rubydb
=== デバッグコマンド
以下は、デバッガで使用......挙げたもの以外を入力した場合、その入力を ruby の式として評価します。
: break
: break [<file>:]<position>|<class>:<method>
ブレークポイントを設定します。引数を省略した場合設定したブレークポ
イントを表示します。......ject>の
インスタンス変数、<object>の定数を表示します。
このコマンドの省略形は v です。
: method i[nstance] <object>
: method <class|module>
それぞれ、オブジェクト<object>のインスタンスメソッド
クラスメソッド または... -
NEWS for Ruby 3
. 0 . 0 (138.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...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 no longer experimental. 17260
* One-line pattern......e, String => x, String => y, *post]
p pre #=> ["a", 1]
p x #=> "b"
p y #=> "c"
p post #=> [2, "d", "e", "f", 3]
end
//}
* Endless method definition is added. [EXPERIMENTAL]
16746
//emlist{
def square(x) = x * x
//}
* Interpolated String literals are no longer frozen when......ault gems
* The following libraries are promoted to default gems from stdlib.
* English
* abbrev
* base64
* drb
* debug
* erb
* find
* net-ftp
* net-http
* net-imap
* net-protocol
* open-uri
* optparse
* pp... -
NEWS for Ruby 3
. 1 . 0 (78.0) -
NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...* MatchData#match_length が追加されました。 18172
* Method / UnboundMethod
* 新規メソッド
* Method#public?, Method#private?, Method#protected?, UnboundMethod#public?, UnboundMethod#private?, UnboundMethod#protected? が追加されました。 11689
* Module
*......ment
* Module#refineで作成されたモジュールを表す新しいクラス。includeとprependは非推奨になり、代わりにimport_methodsが追加されました。
== 標準添付ライブラリの更新(機能追加とバグ修正を除く)
* 以下のdefault gemsが更新さ......更されました。
* net-ftp 0.1.3
* net-imap 0.2.2
* net-pop 0.1.1
* net-smtp 0.3.1
* matrix 0.4.2
* prime 0.1.2
* debug 1.4.0
* 以下が標準添付ライブラリから削除されました。
* dbm
* gdbm
* tracer
* Coverageの計測が一時停... -
Kernel
. # caller(range) -> [String] | nil (60.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...2.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 関......数
のサンプルです。
//emlist[例][ruby]{
$DEBUG = true
def debug(*args)
p [caller.first, *args] if $DEBUG
end
debug "debug information"
#=> ["-:7", "debug information"]
//}... -
Kernel
. # caller(start = 1) -> [String] | nil (60.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...2.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 関......数
のサンプルです。
//emlist[例][ruby]{
$DEBUG = true
def debug(*args)
p [caller.first, *args] if $DEBUG
end
debug "debug information"
#=> ["-:7", "debug information"]
//}... -
Kernel
. # caller(start , length) -> [String] | nil (60.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...2.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 関......数
のサンプルです。
//emlist[例][ruby]{
$DEBUG = true
def debug(*args)
p [caller.first, *args] if $DEBUG
end
debug "debug information"
#=> ["-:7", "debug information"]
//}... -
NEWS for Ruby 2
. 3 . 0 (42.0) -
NEWS for Ruby 2.3.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...g-literal というコマンドラインオプションも導入されました
8976
* コマンドラインオプションに --debug または --debug=frozen-string-literal を付けて実行すると、
freeze された文字列を操作しようとして RuntimeError が発生し......n gem:
* 名前のタイポによって NameError や NoMethodError が起きたときに、自動的に他の似た名前を提案してくれます。
//emlist{
"Yuki".starts_with?("Y")
# => NoMethodError: undefined method `starts_with?' for "Yuki":String
# Did you mean?......を追加
11151
* Proc
* Proc#call ( Proc#[] , Proc#===, Proc#yield) は最適化されました。
Backtrace doesn't show each method (show block lines directly).
TracePoint also ignores these calls.
11569
* Queue (Thread::Queue)
* 終了を通知するため... -
irb (36.0)
-
irb は Interactive Ruby の略です。 irb を使うと、Ruby の式を標準入力から簡単に入力・実行することができます。
...ns:
-f ~/.irbrc を読み込まない
-m bc モード (分数と行列の計算ができる)
-d $DEBUG を true にする (ruby -d と同じ)
-w ruby -w と同じ
-W[level=2] ruby -W と同じ
-r library ruby -r と......参照)
--single-irb irb 中で self を実行して得られるオブジェクトをサブ irb と共
有する
--irb_debug n irb のデバッグレベルを n に設定する
(ユーザは利用すべきではない)
-v, --version irb の......b(main):006:0> irb # サブ irb を起動
irb#1(main):001:0> x # x を表示
NameError: undefined local variable or method `x' for main:Object
from (irb#1):1:in `Kernel#binding'
起動時のインタプリタでローカル変数 x を定義しましたが、
「i......ンドラインオプション
irb [options] file_name opts
options:
-f ~/.irbrc を読み込まない
-d $DEBUG を true にする (ruby -d と同じ)
-w ruby -w と同じ
-W[level=2] ruby -W と同じ
-r library ruby -r と... -
rdoc (36.0)
-
RDoc は Ruby のドキュメント生成を行うためのライブラリです。rdoc という ドキュメント生成のためのコマンドも含んでいます。
...no-dcov
ドキュメントが記述されていない要素に関するレポートを出力しません。
: --debug
実行時に内部情報を出力します。
: --no-debug
実行時に内部情報を出力しません。
: --diagram
何もしません。--diagram オプション......ategory: Utility Methods
#
# CGI escapes +text+
def convert_string text
CGI.escapeHTML text
end
//}
title を省略した場合は、:section: を指定しなかった場合と同じように扱
われます。
//emlist{
# :category:
#
# This method is in the defau......lt category
def some_method
# ...
end
//}
:section: とは異なり、以降のドキュメントには影響しません。直後の要素
のみに影響します。
: :call-seq:
デフォルトではメソッドの引数や yield の引数をパースして出力しますが、... -
制御構造 (24.0)
-
制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END
...に
//emlist[][ruby]{
$_ =~ リテラル
//}
であるかのように評価されます。
==== if 修飾子
//emlist[例][ruby]{
print "debug\n" if $DEBUG
//}
文法:
式 if 式
右辺の条件が成立する時に、左辺の式を評価してその結果を返します。
条件......ったときの値
はnilです。いずれにしてもensure節の値は無視されます。
d:spec/def#class、d:spec/def#module、d:spec/def#method
などの定義文では、それぞれ
begin なしで rescue, ensure 節を定義でき、これにより例外を処理することが
できま......合は Kernel.#at_exit を使
います。
def foo
END { p "end" }
end
p foo
# => -:2: warning: END in method; use at_exit
nil
"end"
END は、BEGIN とは異なり実行時に後処理を登録します。したがっ
て、以...