ライブラリ
- ビルトイン (76)
-
rake
/ testtask (22) - ripper (11)
-
rubygems
/ user _ interaction (22) -
syslog
/ logger (11)
クラス
-
Gem
:: StreamUI (11) - Integer (33)
- Module (24)
-
Rake
:: TestTask (22) - Ripper (11)
- String (11)
-
Syslog
:: Logger (11)
モジュール
-
Gem
:: UserInteraction (11) - Warning (8)
キーワード
- ** (11)
-
alert
_ warning (22) - autoload (4)
-
const
_ set (11) -
deprecate
_ constant (9) - error (11)
- pow (22)
-
to
_ f (11) - warn (8)
- warning= (11)
検索結果
先頭5件
-
Ripper
# warning(fmt , *args) -> nil (30502.0) -
解析した Ruby プログラムの中に重要な警告($-w が false の時だけ出 力される警告)を出力するようなものがあった場合に実行されます。
...y プログラムの中に重要な警告($-w が false の時だけ出
力される警告)を出力するようなものがあった場合に実行されます。
@param fmt エラーメッセージのフォーマット文字列です。
@param args エラーメッセージのフォーマット......される引数です。
サブクラスでオーバライドして使用します。
引数のエラーメッセージは printf フォーマットに従って渡されます。... -
Rake
:: TestTask # warning -> bool (30302.0) -
この値が真である場合、テスト実行時に ruby -w を実行したのと同じ効果が生じます。
この値が真である場合、テスト実行時に ruby -w を実行したのと同じ効果が生じます。 -
Warning
# warn(message) -> nil (24219.0) -
引数 message を標準エラー出力 $stderr に出力します。
...引数 message を標準エラー出力 $stderr に出力します。
Kernel.#warnの挙動を変更する際は、このメソッドではなくクラスメソッドであるWarning.warnをオーバーライドする必要があります。
@param message 出力するオブジェクトを指定......します。
@param category 警告のカテゴリを指定します。サポートされている category については Warning.[] を参照してください。
@see Kernel.#warn, Warning.warn... -
Warning
# warn(message , category: nil) -> nil (24219.0) -
引数 message を標準エラー出力 $stderr に出力します。
...引数 message を標準エラー出力 $stderr に出力します。
Kernel.#warnの挙動を変更する際は、このメソッドではなくクラスメソッドであるWarning.warnをオーバーライドする必要があります。
@param message 出力するオブジェクトを指定......します。
@param category 警告のカテゴリを指定します。サポートされている category については Warning.[] を参照してください。
@see Kernel.#warn, Warning.warn... -
Gem
:: StreamUI # alert _ warning(statement , question = nil) -> String | nil (18518.0) -
WARNING レベルのアラートを表示します。
...
WARNING レベルのアラートを表示します。
@param statement 表示する文字列を指定します。
@param question 必要であれば質問を指定します。
@return question を指定した場合は、それに対する回答を返します。
question を指定しな......い場合は nil を返します。
@see Gem::StreamUI#ask... -
Gem
:: UserInteraction # alert _ warning(*args) -> () (18318.0) -
WARNING レベルのアラートを出力します。
...
WARNING レベルのアラートを出力します。
@param args 委譲先のメソッドに与える引数です。... -
Rake
:: TestTask # warning=(flag) (18302.0) -
テスト実行時に警告を表示させるかどうかをセットします。
...テスト実行時に警告を表示させるかどうかをセットします。
@param flag 真または偽を指定します。... -
Module
# deprecate _ constant(*name) -> self (12225.0) -
name で指定した定数を deprecate に設定します。 deprecate に設定した定数を参照すると警告メッセージが表示されます。
...
name で指定した定数を deprecate に設定します。
deprecate に設定した定数を参照すると警告メッセージが表示されます。
@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
//}......
name で指定した定数を deprecate に設定します。
deprecate に設定した定数を参照すると警告メッセージが表示されます。
Ruby 2.7.2 から Warning[:deprecated] のデフォルト値が false に変更になったため、
デフォルトでは警告が表示さ......ション(詳細はd:spec/rubycmd#cmd_option参照)で、
「-w」か「-W2」などを指定するか、実行中に「Warning[:deprecated] = true」で
変更すると表示されるようになります。
「$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 deprecat... -
Module
# autoload(const _ name , feature) -> nil (6213.0) -
定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。
...数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。
const_name が autoload 設定されていて、まだ定義されてない(ロードされていない)ときは、
autoload する対象を置き換えます。
const_name が(autoloadで......@param const_name String または Symbol で指定します。
なお、const_name には、"::" 演算子を含めることはできません。
つまり、self の直下に定義された定数しか指定できません。
@param feature Kernel.#require と同様な方法で aut......oload する対象を指定する。
//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
class Bar
end
end
# ----- end of /tmp/foo.rb ----
class Foo
autoload :Bar, '/tmp/foo'
end
p Foo::Bar #=> Foo::Bar
//}
以下のようにモジュールを明示的にレシーバとして呼... -
Module
# const _ set(name , value) -> object (6213.0) -
モジュールに name で指定された名前の定数を value とい う値として定義し、value を返します。
...ールに name で指定された名前の定数を value とい
う値として定義し、value を返します。
そのモジュールにおいてすでにその名前の定数が定義されている場合、警
告メッセージが出力されます。
@param name Symbol,String で定数......名前を指定します。
@param value セットしたい値を指定します。
//emlist[例][ruby]{
module Foo; end
# Symbolを指定した場合
Foo.const_set(:FOO, 123)
Foo::FOO # => 123
# Stringを指定した場合
Foo.const_set('BAR', 'abc')
Foo::BAR # => "abc"
# 既に定義されて......いる定数の名前を指定した場合
Foo.const_set('BAR', '123')
# warning: already initialized constant Foo::BAR
# warning: previous definition of BAR was here
# => "123"
# 不適切な定数名を指定した場合
Foo.const_set('foo', 1) # => NameError: wrong constant name foo
//}... -
Integer
# **(other) -> Numeric (3113.0) -
算術演算子。冪(べき乗)を計算します。
...param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@ra......ise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # => 3
3.pow(3, -8) # => -5
3.pow(2, -2) # => -1
-3.pow(3, 8) # => 5
-3.pow(3, -8) # => -3
5.pow(2, -8) # => -7
//}
結果が......数になりそうなとき、警告を出したうえで Float::INFINITY を返します。
//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}
判定の閾値は変わりえます。
@see BigDecimal#power... -
Integer
# pow(other) -> Numeric (3113.0) -
算術演算子。冪(べき乗)を計算します。
...param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@ra......ise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # => 3
3.pow(3, -8) # => -5
3.pow(2, -2) # => -1
-3.pow(3, 8) # => 5
-3.pow(3, -8) # => -3
5.pow(2, -8) # => -7
//}
結果が......数になりそうなとき、警告を出したうえで Float::INFINITY を返します。
//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}
判定の閾値は変わりえます。
@see BigDecimal#power...