るりまサーチ (Ruby 2.5.0)

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

別のキーワード

  1. _builtin times
  2. integer times
  3. process times
  4. times _builtin

ライブラリ

モジュール

キーワード

検索結果

Integer#times -> Enumerator (54364.0)

self 回だけ繰り返します。 self が正の整数でない場合は何もしません。

self 回だけ繰り返します。
self が正の整数でない場合は何もしません。

またブロックパラメータには 0 から self - 1 までの数値が渡されます。

//emlist[][ruby]{
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
//}

@see Integer#upto, Integer#downto,...

Integer#times {|n| ... } -> self (54364.0)

self 回だけ繰り返します。 self が正の整数でない場合は何もしません。

self 回だけ繰り返します。
self が正の整数でない場合は何もしません。

またブロックパラメータには 0 から self - 1 までの数値が渡されます。

//emlist[][ruby]{
3.times { puts "Hello, World!" } # Hello, World! と3行続いて表示される。
0.times { puts "Hello, World!" } # 何も表示されない。
5.times {|n| print n } # 01234 と表示される。
//}

@see Integer#upto, Integer#downto,...

Rake::FileCreationTask#timestamp -> Rake::EarlyTime (18304.0)

どんなタイムスタンプよりも前の時刻をあらわすタイムスタンプを返します。

どんなタイムスタンプよりも前の時刻をあらわすタイムスタンプを返します。


@see [[FileTask#timestamp]]

Rake::FileTask#timestamp -> Time | Rake::LateTime (18304.0)

ファイルタスクのタイムスタンプを返します。

ファイルタスクのタイムスタンプを返します。

//emlist[][ruby]{
# Rakefile での記載例とする

task default: "test.txt"
file "test.txt" do |task|
Rake.application.options.build_all = false
task.timestamp # => #<Rake::LateTime:0x2ba58f0>
end
//}

Rake::Task#timestamp -> Time (18304.0)

自身のタイムスタンプを返します。

自身のタイムスタンプを返します。

基本的なタスクは現在時刻を返しますが、高度なタスクはタイムスタンプを
計算して返します。

絞り込み条件を変える

Socket::AncillaryData#timestamp -> Time (18304.0)

タイムスタンプ制御メッセージに含まれる時刻を Time オブジェクト で返します。

タイムスタンプ制御メッセージに含まれる時刻を Time オブジェクト
で返します。

"タイムスタンプ制御メッセージ" は以下のいずれかです。
* SOL_SOCKET/SCM_TIMESTAMP (micro second) GNU/Linux, FreeBSD, NetBSD, OpenBSD, Solaris, MacOS X
* SOL_SOCKET/SCM_TIMESTAMPNS (nano second) GNU/Linux
* SOL_SOCKET/SCM_BINTIME (2**(-64) second) FreeBSD

require 'socket...

String#*(times) -> String (391.0)

文字列の内容を times 回だけ繰り返した新しい文字列を作成して返します。

文字列の内容を times 回だけ繰り返した新しい文字列を作成して返します。

@param times 整数
@return self を times 回繰り返した新しい文字列

@raise ArgumentError 引数に負数を指定したときに発生します。

//emlist[例][ruby]{
p "str" * 3 # => "strstrstr"

str = "abc"
p str * 4 # => "abcabcabcabc"
p str * 0 # => ""
p str # => "abc" (変化なし)
//}

Array#*(times) -> Array (373.0)

配列の内容を times 回 繰り返した新しい配列を作成して返します。 値はコピーされないことに注意してください。

配列の内容を times 回 繰り返した新しい配列を作成して返します。
値はコピーされないことに注意してください。

@param times 繰り返したい回数を整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッドによ
る暗黙の型変換を試みます。

@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。

@raise ArgumentError 引数に負の数を指定した場合に発生します。

//emlist[例][...

Kernel#modified?(target, times) -> Time | nil (373.0)

target が times の全ての要素よりも新しい場合は target の更新時刻を返します。 そうでない場合は nil を返します。target が存在しない場合も nil を返します。

target が times の全ての要素よりも新しい場合は target の更新時刻を返します。
そうでない場合は nil を返します。target が存在しない場合も nil を返します。

@param target 対象のファイル名を指定します。

@param times Time の配列か Time を一つ指定します。

ARGF.class#eof -> bool (22.0)

現在開いているファイルがEOFに達したらtrueを返します。そうでない場合は falseを返します。

現在開いているファイルがEOFに達したらtrueを返します。そうでない場合は
falseを返します。

@raise IOError ファイルがopenされていない場合に発生します。

$ echo "eof" | ruby argf.rb

ARGF.eof? # => false
3.times { ARGF.readchar }
ARGF.eof? # => false
ARGF.readchar # => "\n"
ARGF.eof? # =...

絞り込み条件を変える

ARGF.class#eof? -> bool (22.0)

現在開いているファイルがEOFに達したらtrueを返します。そうでない場合は falseを返します。

現在開いているファイルがEOFに達したらtrueを返します。そうでない場合は
falseを返します。

@raise IOError ファイルがopenされていない場合に発生します。

$ echo "eof" | ruby argf.rb

ARGF.eof? # => false
3.times { ARGF.readchar }
ARGF.eof? # => false
ARGF.readchar # => "\n"
ARGF.eof? # =...

Binding#local_variables -> [Symbol] (22.0)

ローカル変数の一覧を Symbol の配列で返します。

ローカル変数の一覧を Symbol の配列で返します。

//emlist[例][ruby]{
def foo
a = 1
2.times do |n|
binding.local_variables #=> [:a, :n]
end
end
//}

このメソッドは以下のコードと同様の動作をします。

//emlist[][ruby]{
binding.eval("local_variables")
//}

Enumerator#next -> object (22.0)

「次」のオブジェクトを返します。

「次」のオブジェクトを返します。

現在までの列挙状態に応じて「次」のオブジェクトを返し、列挙状態を1つ分進めます。
列挙が既に最後へ到達している場合は、
StopIteration 例外を発生します。このとき列挙状態は変化しません。
つまりもう一度 next を呼ぶと再び例外が発生します。

next メソッドによる外部列挙の状態は他のイテレータメソッドによる
内部列挙には影響を与えません。
ただし、 IO#each_line のようにおおもとの列挙メカニズムが副作用を
伴っている場合には影響があり得ます。

@raise StopIteration 列挙状態が既に最後へ到達しているとき
@...

Enumerator#with_object(obj) -> Enumerator (22.0)

繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。

繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。

obj には任意のオブジェクトを渡すことができます。

ブロックが渡されなかった場合は、上で説明した繰り返しを実行し、
最後に obj を返す Enumerator を返します。

//emlist[例][ruby]{
# 0,1,2 と呼びだす enumeratorを作る
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end

to_three_with_string = to_three.with_object...

Enumerator#with_object(obj) {|(*args), memo_obj| ... } -> object (22.0)

繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。

繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。

obj には任意のオブジェクトを渡すことができます。

ブロックが渡されなかった場合は、上で説明した繰り返しを実行し、
最後に obj を返す Enumerator を返します。

//emlist[例][ruby]{
# 0,1,2 と呼びだす enumeratorを作る
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end

to_three_with_string = to_three.with_object...

絞り込み条件を変える

Enumerator::Lazy#enum_for(method = :each, *args) -> Enumerator::Lazy (22.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) ...

Enumerator::Lazy#enum_for(method = :each, *args) {|*args| block} -> Enumerator::Lazy (22.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) ...

Enumerator::Lazy#to_enum(method = :each, *args) -> Enumerator::Lazy (22.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) ...

Enumerator::Lazy#to_enum(method = :each, *args) {|*args| block} -> Enumerator::Lazy (22.0)

Object#to_enum と同じですが、Enumerator::Lazy を返します。

Object#to_enum と同じですが、Enumerator::Lazy を返します。

to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が正しく引き継がれるように、Lazy#to_enum は
素のEnumerator ではなく Enumerator::Lazy を返すようになっています。

//emlist[例][ruby]{
module Enumerable
# 要素をn回ずつ繰り返すメソッド
# 例:[1,2,3].repeat(2) ...

Float#next_float -> Float (22.0)

浮動小数点数で表現可能な self の次の値を返します。

浮動小数点数で表現可能な self の次の値を返します。

Float::MAX.next_float、Float::INFINITY.next_float は
Float::INFINITY を返します。Float::NAN.next_float は
Float::NAN を返します。

//emlist[例][ruby]{
p 0.01.next_float # => 0.010000000000000002
p 1.0.next_float # => 1.0000000000000002
p 100.0.next_float # => 100.00000000000001

p ...

絞り込み条件を変える

Float#prev_float -> Float (22.0)

浮動小数点数で表現可能な self の前の値を返します。

浮動小数点数で表現可能な self の前の値を返します。

(-Float::MAX).prev_float と (-Float::INFINITY).prev_float
は -Float::INFINITY を返します。Float::NAN.prev_float は
Float::NAN を返します。

//emlist[例][ruby]{
p 0.01.prev_float # => 0.009999999999999998
p 1.0.prev_float # => 0.9999999999999999
p 100.0.prev_float # => 99.9999999999...

Integer#downto(min) -> Enumerator (22.0)

self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。

self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。

@param min 数値
@return self を返します。

//emlist[][ruby]{
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
//}

@see Integer#upto, Numeric#step, Integer#times

Integer#downto(min) {|n| ... } -> self (22.0)

self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。 self < min であれば何もしません。

self から min まで 1 ずつ減らしながらブロックを繰り返し実行します。
self < min であれば何もしません。

@param min 数値
@return self を返します。

//emlist[][ruby]{
5.downto(1) {|i| print i, " " } # => 5 4 3 2 1
//}

@see Integer#upto, Numeric#step, Integer#times

Integer#upto(max) -> Enumerator (22.0)

self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。

self から max まで 1 ずつ増やしながら繰り返します。
self > max であれば何もしません。

@param max 数値
@return self を返します。

//emlist[][ruby]{
5.upto(10) {|i| print i, " " } # => 5 6 7 8 9 10
//}

@see Integer#downto, Numeric#step, Integer#times

Integer#upto(max) {|n| ... } -> Integer (22.0)

self から max まで 1 ずつ増やしながら繰り返します。 self > max であれば何もしません。

self から max まで 1 ずつ増やしながら繰り返します。
self > max であれば何もしません。

@param max 数値
@return self を返します。

//emlist[][ruby]{
5.upto(10) {|i| print i, " " } # => 5 6 7 8 9 10
//}

@see Integer#downto, Numeric#step, Integer#times

絞り込み条件を変える

Object#enum_for(method = :each, *args) -> Enumerator (22.0)

Enumerator.new(self, method, *args) を返します。

Enumerator.new(self, method, *args) を返します。

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

#...

Object#enum_for(method = :each, *args) {|*args| ... } -> Enumerator (22.0)

Enumerator.new(self, method, *args) を返します。

Enumerator.new(self, method, *args) を返します。

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

#...

Object#to_enum(method = :each, *args) -> Enumerator (22.0)

Enumerator.new(self, method, *args) を返します。

Enumerator.new(self, method, *args) を返します。

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

#...

Object#to_enum(method = :each, *args) {|*args| ... } -> Enumerator (22.0)

Enumerator.new(self, method, *args) を返します。

Enumerator.new(self, method, *args) を返します。

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

#...

Thread::ConditionVariable#broadcast -> self (22.0)

状態変数を待っているスレッドをすべて再開します。再開された スレッドは Thread::ConditionVariable#wait で指定した mutex のロックを試みます。

状態変数を待っているスレッドをすべて再開します。再開された
スレッドは Thread::ConditionVariable#wait
で指定した mutex のロックを試みます。

@return 常に self を返します。

//emlist[例][ruby]{
mutex = Mutex.new
cv = ConditionVariable.new
flg = true

3.times {
Thread.start {
mutex.synchronize {
puts "a1"
while (flg)
cv.wait(mutex)
...

絞り込み条件を変える

Thread::ConditionVariable#signal -> self (22.0)

状態変数を待っているスレッドを1つ再開します。再開された スレッドは Thread::ConditionVariable#wait で指定した mutex のロックを試みます。

状態変数を待っているスレッドを1つ再開します。再開された
スレッドは Thread::ConditionVariable#wait
で指定した mutex のロックを試みます。

@return 常に self を返します。

//emlist[例][ruby]{
mutex = Mutex.new
cv = ConditionVariable.new
flg = true

3.times {
Thread.start {
mutex.synchronize {
puts "a1"
while (flg)
cv.wait(mutex)
...

ThreadsWait#all_waits -> () (22.0)

指定されたスレッドすべてが終了するまで待ちます。 ブロックが与えられた場合、スレッド終了時にブロックを評価します。

指定されたスレッドすべてが終了するまで待ちます。
ブロックが与えられた場合、スレッド終了時にブロックを評価します。

使用例
require 'thwait'

threads = []
5.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}

thall = ThreadsWait.new(*threads)
thall.all_waits{|th|
printf("end %s\n", th.inspect)
}

# 出力例
#=> #<Thread...

ThreadsWait#empty? -> bool (22.0)

同期されるスレッドが存在するならば true をかえします。

同期されるスレッドが存在するならば true をかえします。

使用例
require 'thwait'

threads = []
3.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}

thall = ThreadsWait.new
p thall.threads.empty? #=> true
thall.join(*threads)
p thall.threads.empty? #=> false

ThreadsWait#finished? -> bool (22.0)

すでに終了したスレッドが存在すれば true を返します。

すでに終了したスレッドが存在すれば true を返します。

使用例
require 'thwait'

threads = []
3.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}

thall = ThreadsWait.new(*threads)
p thall.finished? #=> false
sleep 3
p thall.finished? #=> true

ThreadsWait#join(*threads) -> () (22.0)

終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。

終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。

@param threads 複数スレッドの終了を待つスレッドに指定されたthreadsを加えます。

require 'thwait'

threads = []
5.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}

thall = ThreadsWait.new
p thall.threads #=> []
thall.join(*threads)
p thall.threads
...

絞り込み条件を変える

ThreadsWait#join_nowait(*threads) -> () (22.0)

終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。 しかし、実際には終了をまちません。

終了を待つスレッドの対象として、threads で指定されたスレッドを指定します。
しかし、実際には終了をまちません。

@param threads 複数スレッドの終了を待つスレッドに指定されたthreadsを加えます。

require 'thwait'

threads = []
5.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}

thall = ThreadsWait.new
p thall.threads #=> []
thall.join_nowait(*thr...

ThreadsWait#next_wait(nonblock = nil) -> Thread (22.0)

指定したスレッドのどれかが終了するまで待ちます。

指定したスレッドのどれかが終了するまで待ちます。

@param nonblock true を与えると、キューが空の時、例外 ThreadsWait::ErrNoFinishedThread が発生します。

@raise ErrNoWaitingThread 終了をまつスレッドが存在しない時、発生します。

@raise ErrNoFinishedThread nonblock がtrue でかつ、キューが空の時、発生します。

#使用例
require 'thwait'

threads = []
2.times {|i|
threads << Thread.n...

ThreadsWait#threads -> Array (22.0)

同期されるスレッドの一覧を配列で返します。

同期されるスレッドの一覧を配列で返します。

使用例
require 'thwait'

threads = []
3.times {|i|
threads << Thread.new { sleep 1; p Thread.current }
}

thall = ThreadsWait.new(*threads)
p thall.threads
#=> [#<Thread:0x21750 sleep>, #<Thread:0x216c4 sleep>, #<Thread:0x21638 sleep>]

Array#*(sep) -> String (13.0)

指定された sep を間にはさんで連結した文字列を生成して返します。Array#join(sep) と同じ動作をします。

指定された sep を間にはさんで連結した文字列を生成して返します。Array#join(sep) と同じ動作をします。

@param sep 文字列を指定します。
文字列以外のオブジェクトを指定した場合は to_str メソッドによ
る暗黙の型変換を試みます。

//emlist[例][ruby]{
p [1,2,3] * ","
# => "1,2,3"
//}

@see Array#join