別のキーワード
クラス
- Array (57)
- BasicObject (24)
- Set (3)
- String (31)
- Thread (92)
-
Thread
:: Queue (30) -
Thread
:: SizedQueue (30)
キーワード
- * (24)
- [] (12)
-
_ _ send _ _ (24) -
abort
_ on _ exception (12) -
abort
_ on _ exception= (12) -
add
_ trace _ func (12) - deq (20)
- disjoint? (3)
- fetch (8)
- pack (21)
- pop (20)
-
set
_ trace _ func (12) - shift (20)
- split (19)
- unpack (12)
検索結果
先頭5件
-
Array
# join(sep = $ , ) -> String (18140.0) -
配列の要素を文字列 sep を間に挟んで連結した文字列を返します。
...して)
join した文字列を連結します。
ただし、配列要素が自身を含むような無限にネストした配列に対しては、以下
のような結果になります。
//emlist[例][ruby]{
ary = [1,2,3]
ary.push ary
p ary # => [1, 2, 3, [...]]
p ary.join # =>......ArgumentError: recursive array join
//}
@param sep 間に挟む文字列を指定します。nil のときは空文字列を使います。
文字列以外のオブジェクトを指定した場合は to_str メソッドによ
る暗黙の型変換を試みます。
@raise T......を指定した場合に発生します。
@raise ArgumentError 配列要素が自身を含むような無限にネストした配列に対
して join を呼んだ場合に発生します。
//emlist[例][ruby]{
[1, 2, 3].join('-') #=> "1-2-3"
//}
@see Array#*, $,... -
Thread
# join -> self (18129.0) -
スレッド self の実行が終了するまで、カレントスレッドを停止し ます。self が例外により終了していれば、その例外がカレントス レッドに対して発生します。
...を返します。
@param limit タイムアウトする時間を整数か小数で指定します。単位は秒です。
@raise ThreadError join を実行することによってデッドロックが起きる場合に発生します。またカレントスレッドを join したときにも発......。
以下は、生成したすべてのスレッドの終了を待つ例です。
threads = []
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.each {|t| t.join}... -
Thread
# join(limit) -> self | nil (18129.0) -
スレッド self の実行が終了するまで、カレントスレッドを停止し ます。self が例外により終了していれば、その例外がカレントス レッドに対して発生します。
...を返します。
@param limit タイムアウトする時間を整数か小数で指定します。単位は秒です。
@raise ThreadError join を実行することによってデッドロックが起きる場合に発生します。またカレントスレッドを join したときにも発......。
以下は、生成したすべてのスレッドの終了を待つ例です。
threads = []
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.push(Thread.new { n = rand(5); sleep n; n })
threads.each {|t| t.join}... -
Set
# disjoint?(set) -> bool (6109.0) -
self と set が互いに素な集合である場合に true を返します。
...tersect? を
使用します。
@param self Set オブジェクトを指定します。
@raise ArgumentError 引数が Set オブジェクトでない場合に発生します。
//emlist[][ruby]{
p Set[1, 2, 3].disjoint? Set[3, 4] # => false
p Set[1, 2, 3].disjoint? Set[4, 5] # => true
//}
@see S... -
Array
# *(sep) -> String (32.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... -
Array
# pack(template) -> String (27.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
...fer: 'abc') # => "a!"
['!'].pack('@5a', buffer: 'abc') # => "abc\u0000\u0000!"
//}
@param template 自身のバイナリとしてパックするためのテンプレートを文字列で指定します。
@param buffer 結果を詰めるバッファとして使う文字列オブジェクトを......98, 121].pack("c*") # => "Ruby"
s = ""
[82, 117, 98, 121].each {|c| s << c}
s # => "Ruby"
[82, 117, 98, 121].collect {|c| sprintf "%c", c}.join # => "Ruby"
[82, 117, 98, 121].inject("") {|s, c| s << c} # => "Ruby"
//}
: 文字列を数値(文字コード)の配列に変換する例
/......e, alias_hostnames, address_family, *address_list = Socket.gethostbyname("localhost")
address_list.find {|address| address.size == 4 }.unpack("C4").join(".")
# => "127.0.0.1"
"127.0.0.1".split(".").collect {|c| c.to_i}.pack("C4")
# => "\x7F\x00\x00\x01"
//}
: sockaddr_in 構造体
//emlist[][ruby]... -
Array
# pack(template , buffer: String . new) -> String (27.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
...fer: 'abc') # => "a!"
['!'].pack('@5a', buffer: 'abc') # => "abc\u0000\u0000!"
//}
@param template 自身のバイナリとしてパックするためのテンプレートを文字列で指定します。
@param buffer 結果を詰めるバッファとして使う文字列オブジェクトを......98, 121].pack("c*") # => "Ruby"
s = ""
[82, 117, 98, 121].each {|c| s << c}
s # => "Ruby"
[82, 117, 98, 121].collect {|c| sprintf "%c", c}.join # => "Ruby"
[82, 117, 98, 121].inject("") {|s, c| s << c} # => "Ruby"
//}
: 文字列を数値(文字コード)の配列に変換する例
/......e, alias_hostnames, address_family, *address_list = Socket.gethostbyname("localhost")
address_list.find {|address| address.size == 4 }.unpack("C4").join(".")
# => "127.0.0.1"
"127.0.0.1".split(".").collect {|c| c.to_i}.pack("C4")
# => "\x7F\x00\x00\x01"
//}
: sockaddr_in 構造体
//emlist[][ruby]... -
BasicObject
# _ _ send _ _ (name , *args) -> object (27.0) -
オブジェクトのメソッド name を args を引数にして呼び出し、メソッドの結果を返します。
...まま引き渡します。
@param name 呼び出すメソッドの名前。 Symbol または文字列で指定します。
@param args メソッドに渡す任意個の引数
//emlist[例][ruby]{
class Mail
def delete(*args)
"(Mail#delete) - delete " + args.join(',')
end
def send(name,......*args)
"(Mail#send) - #{name} #{args.join(',')}"
end
end
mail = Mail.new
mail.send :delete, "gentle", "readers" # => "(Mail#send) - delete gentle,readers"
mail.__send__ :delete, "gentle", "readers" # => "(Mail#delete) - delete gentle,readers"
//}
@see Object#send... -
BasicObject
# _ _ send _ _ (name , *args) { . . . . } -> object (27.0) -
オブジェクトのメソッド name を args を引数にして呼び出し、メソッドの結果を返します。
...まま引き渡します。
@param name 呼び出すメソッドの名前。 Symbol または文字列で指定します。
@param args メソッドに渡す任意個の引数
//emlist[例][ruby]{
class Mail
def delete(*args)
"(Mail#delete) - delete " + args.join(',')
end
def send(name,......*args)
"(Mail#send) - #{name} #{args.join(',')}"
end
end
mail = Mail.new
mail.send :delete, "gentle", "readers" # => "(Mail#send) - delete gentle,readers"
mail.__send__ :delete, "gentle", "readers" # => "(Mail#delete) - delete gentle,readers"
//}
@see Object#send... -
String
# split(sep = $ ; , limit = 0) -> [String] (27.0) -
第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。
...なしで、配列末尾の空文字列を取り除く
: limit < 0
分割個数の制限はなし
@param sep 文字列を分割するときのセパレータのパターン
@param limit 分割する最大個数
//emlist[例][ruby]{
p " a \t b \n c".split(/\s+/) # => ["", "a", "......列にマッチする場合は 1 文字に分割][ruby]{
p 'hi there'.split(/\s*/).join(':') # => "h:i:t:h:e:r:e"
//}
//emlist[文字列全体を 1 文字ずつに分割する例][ruby]{
p 'hi there'.split(//).join(':') # => "h:i: :t:h:e:r:e"
//}
//emlist[limit == 0 だと制限なく分割......なしで、配列末尾の空文字列を取り除く
: limit < 0
分割個数の制限はなし
@param sep 文字列を分割するときのセパレータのパターン
@param limit 分割する最大個数
@return ブロックを渡した場合は self、ブロックなしの...