種類
- モジュール関数 (206)
- インスタンスメソッド (93)
- 文書 (63)
- 特異メソッド (18)
キーワード
- ** (11)
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (5) - Rubyの起動 (4)
- [] (1)
- alert (12)
- close (12)
- crit (12)
- debug (12)
-
deprecate
_ constant (12) - emerg (12)
- err (12)
- fetch (36)
- info (12)
- lambda (18)
- mask (12)
- mask= (12)
- new (17)
- notice (12)
- open (28)
- pow (22)
- proc (19)
-
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 4 feature (12) - sysseek (12)
- warn (9)
- 制御構造 (12)
検索結果
先頭5件
-
Syslog
. # warning(message , *arg) -> self (15113.0) -
Syslog#log()のショートカットメソッド。 システムによっては定義されていないものもあります。
...rintf と同じ形式の引数を指定します。
@param arg フォーマットされる引数です。
@raise ArgumentError 引数が1つ以上でない場合に発生します。
@raise RuntimeError syslog がopen されていない場合発生します。
例:
require 'syslog'
Syslog.op... -
ruby 1
. 6 feature (162.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...が、この変更は元に戻りました。
p "#{ "" }"
=> ruby 1.6.7 (2002-03-01) [i586-linux]
""
=> -:1: warning: bad substitution in string
ruby 1.6.7 (2002-09-12) [i586-linux]
"#{ }"
=> ruby 1.6.7 (2002-09-25) [i586-linux]......gexp.quote("#")
p /a#{Regexp.quote("#")}b/x =~ "ab"
=> -:3: warning: ambiguous first argument; make sure
ruby 1.6.7 (2002-03-01) [i586-linux]
"#"
0
=> -:3: warning: ambiguous first argument; make sure
ruby 1.6.7 (2002-07-30) [i58......(rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) {
+ if (rb_safe_level() >= 4 && (klass == rb_cObject || !OBJ_TAINTED(klass))) {
rb_raise(rb_eSecurityError, "Insecure: can't define method");
}
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
また今度... -
制御構造 (112.0)
-
制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END
...* if
* unless
* case
繰り返し:
* while
* until
* for
* break
* next
* redo
* retry
例外処理:
* raise
* begin
その他:
* return
* BEGIN
* END
Rubyでは(Cなどとは異なり)制御構造は式であって、何らかの値を......gin
do_something # exception raised
rescue
# handles error
retry # restart from beginning
end
//}
rescue 節以外で retry が用いられた場合には例外 SyntaxError が発生
します。
=== 例外処理
====[a:raise] raise
//emlist[例][ruby]{
raise "you lose" # 例外 RuntimeE......により例外を処理することが
できます。
==== rescue修飾子
//emlist[例][ruby]{
open("nonexistent file") rescue STDERR.puts "Warning: #$!"
//}
文法:
式1 rescue 式2
式1で例外が発生したとき、式2を評価します。
以下と同じ意味です。捕捉... -
NEWS for Ruby 2
. 7 . 0 (96.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...oo(**h) # {} and warning
h = {}; def foo(*a) a end; foo(h) # [{}]
h = {}; def foo(a) a end; foo(h) # {}
//}
* 非推奨に関する警告を止めたい場合は、コマンドライン引数に
「-W:no-deprecated」を指定するか、コードの中で
「Warning[:deprecated] =......ーカル変数名として使えて、ローカル変数が優先されますが、
警告が表示されます。
_1 = 0 #=> warning: `_1' is reserved for numbered parameter; consider another name
[1].each { p _1 } # prints 0 instead of 1
==== ブロックなしの proc/lambda......ュメントの識別子の引用符は同じ行で閉じる必要があります。
//emlist{
<<"EOS
" # This had been warned since 2.4; Now it raises a SyntaxError
EOS
//}
* フリップフロップが非推奨になったのが元に戻されました。 5400
* 以下のような場所に... -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (78.0) -
1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))
...は Proc, Method オブジェクト限定でした。
これに伴い Proc#to_proc が追加されました。
: 終了ステータス [compat]
raise SystemExit したときに終了ステータス 1 で終了するようになりました。
((<ruby-dev:16776>))
: ((<"rescue/ensure on begi......。
# # derived from sample/test.rb
# a = *[]; p a # special case
# def f; yield; end; f {|a| p a} # add (warning)
# def r; return; end; a = r(); p a
# a = nil; p a
# def f; yield nil; end; f {|a| p a}
# def r; return nil; end; a = r(); p a
#......d *1; end; f {|a| p a}
# def r; return *1; end; a = r(); p a
# a = *[]; p a
# def f; yield *[]; end; f {|a| p a} # add (warning)
# def r; return *[]; end; a = r(); p a
# a = *[1]; p a
# def f; yield *[1]; end; f {|a| p a}
# def r; return *[1]; end; a = r(); p a... -
Kernel
. # warn(*message , uplevel: nil , category: nil) -> nil (48.0) -
message を 標準エラー出力 $stderr に出力します。 $VERBOSE フラグ が nil のときは何も出力しません。
...定します。サポートされている category については Warning.[] を参照してください。
@raise IOError 標準エラー出力が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX 出力に失敗した場合に発生します。
//emlist......warn("test message", uplevel: 0) # => test.rb:2: warning: test message
warn("test message", uplevel: 1) # => test.rb:6: warning: test message
warn("test message", uplevel: 2) # => test message
end
foo
//}
//emlist[category の例][ruby]{
Warning[:deprecated] = true # 非推奨の警告を表......示する
warn("deprecated!!", category: :deprecated)
# => deprecated!
Warning[:deprecated] = false # 非推奨の警告を表示しない
warn("deprecated!!", category: :deprecated)
# 警告は出力されない
//}
@see Warning#warn, $stderr,$VERBOSE... -
NEWS for Ruby 3
. 0 . 0 (48.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ださい。
== 言語仕様の変更
* Keyword arguments are now separated from positional arguments.
Code that resulted in deprecation warnings in Ruby 2.7 will now
result in ArgumentError or different behavior. 14183
* Procs accepting a single rest argument and keywords are no longe......r = proc{|*a, **kw| [a, kw]}
pr.call([1])
# 2.7 => [[1], {}]
# 3.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, ...)
se......`false`. 17371
//emlist{
0 => a
p a #=> 0
{b: 0, c: 1} => {b:}
p b #=> 0
//}
//emlist{
# version 3.0
0 in 1 #=> false
# version 2.7
0 in 1 #=> raise NoMatchingPatternError
//}
* Find-pattern is added. [EXPERIMENTAL]
16828
//emlist{
case ["a", 1, "b", "c", 2, "d", "e", "f", 3]
in [*pre,... -
Kernel
. # warn(*message , uplevel: nil) -> nil (30.0) -
message を 標準エラー出力 $stderr に出力します。 $VERBOSE フラグ が nil のときは何も出力しません。
...示するかを0以上の数値で指定します。 nil の場合は表示しません。
@raise IOError 標準エラー出力が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX 出力に失敗した場合に発生します。
//emlist[例][ruby]{
warn "c......い
//}
//emlist[uplevel の例][ruby]{
def foo
warn("test message", uplevel: 0) # => test.rb:2: warning: test message
warn("test message", uplevel: 1) # => test.rb:6: warning: test message
warn("test message", uplevel: 2) # => test message
end
foo
//}
@see Warning#warn, $stderr,$VERBOSE... -
Module
# deprecate _ constant(*name) -> self (30.0) -
name で指定した定数を deprecate に設定します。 deprecate に設定した定数を参照すると警告メッセージが表示されます。
...ら Warning[:deprecated] のデフォルト値が false に変更になったため、
デフォルトでは警告が表示されません。
コマンドラインオプション(詳細はd:spec/rubycmd#cmd_option参照)で、
「-w」か「-W2」などを指定するか、実行中に「Warning[:d......れるようになります。
「$VERBOSE = true」は「Warning[:deprecated]」に影響しないため、
表示されるかどうかは変わりません。
@param name 0 個以上の String か Symbol を指定します。
@raise NameError 存在しない定数を指定した場合に発生......します。
@return self を返します。
//emlist[例][ruby]{
FOO = 123
Object.deprecate_constant(:FOO) # => Object
FOO
# warning: constant ::FOO is deprecated
# => 123
Object.deprecate_constant(:BAR)
# NameError: constant Object::BAR not defined
//}... -
Kernel
. # open(name , mode = & # 39;r& # 39; , perm = nil , options = {}) -> StringIO | Tempfile | IO (24.0) -
name が http:// や ftp:// で始まっている文字列なら URI のリソースを 取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。 返されるオブジェクトは OpenURI::Meta モジュールで extend されています。
...2.7以降、open-uriにより拡張されたKernel.openでURLを開くときにwarningが表示されるようになりました。
require 'open-uri'
open("http://www.ruby-lang.org/") {|f|
# ...
}
#=> warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or us......くは OpenURI.open_uri を参照してください。
@raise OpenURI::HTTPError 対象となる URI のスキームが http であり、
かつリソースの取得に失敗した時に発生します。
@raise Net::FTPError 対象となる URI のスキームが ftp で... -
Kernel
. # open(name , mode = & # 39;r& # 39; , perm = nil , options = {}) {|ouri| . . . } -> object (24.0) -
name が http:// や ftp:// で始まっている文字列なら URI のリソースを 取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。 返されるオブジェクトは OpenURI::Meta モジュールで extend されています。
...2.7以降、open-uriにより拡張されたKernel.openでURLを開くときにwarningが表示されるようになりました。
require 'open-uri'
open("http://www.ruby-lang.org/") {|f|
# ...
}
#=> warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or us......くは OpenURI.open_uri を参照してください。
@raise OpenURI::HTTPError 対象となる URI のスキームが http であり、
かつリソースの取得に失敗した時に発生します。
@raise Net::FTPError 対象となる URI のスキームが ftp で... -
IO
# sysseek(offset , whence = IO :: SEEK _ SET) -> Integer (18.0) -
lseek(2) と同じです。IO#seek では、 IO#sysread, IO#syswrite と併用すると正しく動作しないので代わりにこのメソッドを使います。 位置 offset への移動が成功すれば移動した位置(ファイル先頭からのオフセット)を返します。
...# => -:3:in `sysseek': sysseek for buffered IO (IOError)
File.open("/dev/null", "w") {|f|
f.print "foo"
f.sysseek(0)
}
# => -:3: warning: sysseek for buffered IO
@param offset ファイルポインタを移動させるオフセットを整数で指定します。
@param whence......以降の次にホールがある位置へ(同上)
@raise IOError 読み込み用にバッファリングされた IO に対して実行すると発生します。
既に close されていた場合にも発生します。
@raise Errno::EXXX 移動に失敗した場合に発生し... -
Integer
# **(other) -> Numeric (18.0) -
算術演算子。冪(べき乗)を計算します。
...値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//emlist[][rub......になりそうなとき、警告を出したうえで Float::INFINITY を返します。
//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}
判定の閾値は変わりえます。
@see BigDecimal#power...