るりまサーチ

最速Rubyリファレンスマニュアル検索!
1193件ヒット [801-900件を表示] (0.149秒)

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< < ... 7 8 9 10 11 ... > >>

Kernel.#loop { ... } -> object | nil (3126.0)

(中断されない限り)永遠にブロックの評価を繰り返します。 ブロックが指定されなければ、代わりに Enumerator を返します。

...ければ、代わりに Enumerator を返します。

//emlist[例][ruby]{
loop do
print "Input: "
line = gets
break if !line or line =~ /^qQ/
# ...
e
nd
//}

与えられたブロック内で StopIteration を Kernel.#raise すると
ループを終了して Enumerator が最後に返し...
...ます。
ループを終了させる場合、通常は break を使用してください。

//emlist[例][ruby]{
e
num = Enumerator.new { |y|
y << "one"
y << "two"
:ok
}

result = loop {
puts enum.next
} # => :ok
//}


@return break の引数など、ループ脱出時の値を返します...

Kernel.#p(*arg) -> object | Array (3126.0)

引数を人間に読みやすい形に整形して改行と順番に標準出力 $stdout に出力します。主にデバッグに使用します。

...使用します。

引数の inspect メソッドの返り値と改行を順番に出力します。つまり以下のコードと同じです。

//emlist[例][ruby]{
print arg[0].inspect, "\n", arg[1].inspect, "\n" #, ...
//}

整形に用いられるObject#inspectは普通に文字列に変換...
...出力するオブジェクトを任意個指定します。
@raise IOError 標準出力が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX 出力に失敗した場合に発生します。
@return 指定された引数 arg を返します。複数の引数...
...が指定された場合はそれらを要素とする配列を返します。

//emlist[例][ruby]{
puts "" #=> (空行)
p "" #=> ""

puts 50,"50"
#=> 50
#=> 50
p 50,"50"
#=> 50
#=> "50"
//}

@see Object#inspect,Kernel.#puts,Kernel.#print...

Kernel.#warn(*message) -> nil (3126.0)

message を 標準エラー出力 $stderr に出力します。 $VERBOSE フラグ が nil のときは何も出力しません。

...message を 標準エラー出力 $stderr に出力します。 $VERBOSE
フラグ が nil のときは何も出力しません。

文字列以外のオブジェクトが引数として与えられた場合には、
to_s メソッドにより文字列に変換してから出力します。

この...
...//emlist[][ruby]{
$stderr.puts(*message) if !$VERBOSE.nil? && !message.empty?
nil
//}

@param message 出力するオブジェクトを任意個指定します。
@raise IOError 標準エラー出力が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX 出...
...力に失敗した場合に発生します。

//emlist[例][ruby]{
warn "caution!" #=> caution!
$VERBOSE = nil
warn "caution!" # 何もしない
//}



@see $stderr,$VERBOSE...
...力に失敗した場合に発生します。

//emlist[例][ruby]{
warn "caution!" #=> caution!
$VERBOSE = nil
warn "caution!" # 何もしない
//}



@see Warning#warn, $stderr,$VERBOSE...

Kernel.#autoload(const_name, feature) -> nil (3114.0)

定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。

...数 const_name を最初に参照した時に feature
Kernel
.#require するように設定します。

const_name には、 "::" 演算子を含めることはできません。
ネストした定数を指定する方法は Module#autoload を参照してください。

const_name が autoloa...
...
const_name が(autoloadではなく)既に定義されているときは何もしません。

@param const_name 定数をString または Symbol で指定します。
@param feature require と同様な方法で autoload する対象を指定します。
@raise LoadError featureのロードに...
...失敗すると発生します。

//emlist[][ruby]{
# ------- /tmp/foo.rb ---------
class Bar
e
nd
# ----- end of /tmp/foo.rb ----

autoload :Bar, '/tmp/foo'
p Bar #=> Bar
//}

@see Kernel.#autoload?,Module#autoload,Kernel.#require...

Kernel.#autoload?(const_name) -> String | nil (3114.0)

const_name が Kernel.#autoload 設定されているか調べます。

...const_name Kernel.#autoload 設定されているか調べます。

autoload 設定されていて、autoload 定数がまだ定義されてない(ロードされていない)
ときにそのパス名を返します。

autoload 設定されていないか、ロード済みなら nil を返し...
...ます。

@param const_name 定数をString または Symbol で指定します。

//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
class Bar
e
nd
e
nd
# ----- end of /tmp/foo.rb ----

class Foo
e
nd
p Foo.autoload?(:Bar) #=> nil
Foo.autoload :Bar, '/tmp/foo'
p Foo.autoload?...
...(:Bar) #=> "/tmp/foo"
p Foo::Bar #=> Foo::Bar
p Foo.autoload?(:Bar) #=> nil
//}

@see Kernel.#autoload...

絞り込み条件を変える

Kernel.#catch {|tag| .... } -> object (3114.0)

Kernel.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

...
Kernel
.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

ブロックの実行中に tag と同一のオブジェクトを引数とする Kernel.#throw が行われた
場合は、その throw の第二引数を戻り値として、ブロック...
...
@return ブロックの返り値か、対応するthrowの第二引数を返り値として返します。

//emlist[例][ruby]{
result = catch do |tag|
for i in 1..2
for j in 1..2
for k in 1..2
throw tag, k
e
nd
e
nd
e
nd
e
nd

p result #=> 1
//}

@see Kernel.#throw...

Kernel.#catch(tag) {|tag| .... } -> object (3114.0)

Kernel.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

...
Kernel
.#throwとの組み合わせで大域脱出を行います。 catch はブロックを実行します。

ブロックの実行中に tag と同一のオブジェクトを引数とする Kernel.#throw が行われた
場合は、その throw の第二引数を戻り値として、ブロック...
...
@return ブロックの返り値か、対応するthrowの第二引数を返り値として返します。

//emlist[例][ruby]{
result = catch do |tag|
for i in 1..2
for j in 1..2
for k in 1..2
throw tag, k
e
nd
e
nd
e
nd
e
nd

p result #=> 1
//}

@see Kernel.#throw...

Kernel.#gsub(pattern) {|matched| ... } -> String (3114.0)

$_.gsub とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。 コマンドラインオプションで -p または -n を指定した時のみ定義されます。

...@param pattern 置き換える文字列のパターンを表す文字列か正規表現。
文字列を指定した場合は全く同じ文字列にだけマッチする
@param replace pattern で指定した文字列と置き換える文字列

//emlist[例][ruby]{
$_...
...# => "test\n"
gsub(/es/, '!!') # => "t!!t\n"
//}

@see String#gsub,$_...

Kernel.#gsub(pattern, replace) -> String (3114.0)

$_.gsub とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。 コマンドラインオプションで -p または -n を指定した時のみ定義されます。

...@param pattern 置き換える文字列のパターンを表す文字列か正規表現。
文字列を指定した場合は全く同じ文字列にだけマッチする
@param replace pattern で指定した文字列と置き換える文字列

//emlist[例][ruby]{
$_...
...# => "test\n"
gsub(/es/, '!!') # => "t!!t\n"
//}

@see String#gsub,$_...

Kernel.#loop -> Enumerator (3114.0)

(中断されない限り)永遠にブロックの評価を繰り返します。 ブロックが指定されなければ、代わりに Enumerator を返します。

...クが指定されなければ、代わりに Enumerator を返します。

//emlist[例][ruby]{
loop do
print "Input: "
line = gets
break if !line or line =~ /^qQ/
# ...
e
nd
//}

与えられたブロック内で StopIteration を Kernel.#raise すると
ループを終了して nil を返...
...します。
ループを終了させる場合、通常は break を使用してください。

@return break の引数など、ループ脱出時の値を返します。...

絞り込み条件を変える

Kernel.#loop { ... } -> object | nil (3114.0)

(中断されない限り)永遠にブロックの評価を繰り返します。 ブロックが指定されなければ、代わりに Enumerator を返します。

...クが指定されなければ、代わりに Enumerator を返します。

//emlist[例][ruby]{
loop do
print "Input: "
line = gets
break if !line or line =~ /^qQ/
# ...
e
nd
//}

与えられたブロック内で StopIteration を Kernel.#raise すると
ループを終了して nil を返...
...します。
ループを終了させる場合、通常は break を使用してください。

@return break の引数など、ループ脱出時の値を返します。...

Kernel.#pp(*obj) -> object (3114.0)

指定されたオブジェクト obj を標準出力に見やすい形式(プリティプリント)で出力します。 obj それぞれを引数として PP.pp を呼ぶことと同等です。

...P.pp を呼ぶことと同等です。


@param obj 表示したいオブジェクトを指定します。

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

b = [1, 2, 3] * 4
a = [b, b]
a << a
pp a

#=> [[1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],
# [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],
# [...]]
//}

@see PP.pp...
...自動的に pp を require します。

@param obj 表示したいオブジェクトを指定します。

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

b = [1, 2, 3] * 4
a = [b, b]
a << a
pp a

#=> [[1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],
# [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],
# [...]]
//}

@see PP.pp...
<< < ... 7 8 9 10 11 ... > >>