別のキーワード
ライブラリ
- ビルトイン (475)
-
net
/ http (24) - optparse (24)
- pathname (12)
- set (9)
- shell (6)
-
shell
/ command-processor (6) -
shell
/ filter (6) - shellwords (12)
- thread (14)
- thwait (24)
- tsort (23)
- win32ole (12)
- zlib (24)
クラス
- Array (87)
- BasicObject (24)
- Mutex (4)
- OptionParser (24)
- Pathname (12)
- Set (12)
- Shell (6)
-
Shell
:: CommandProcessor (6) -
Shell
:: Filter (6) - String (31)
- Thread (164)
-
Thread
:: Mutex (20) -
Thread
:: Queue (48) -
Thread
:: SizedQueue (36) - ThreadsWait (24)
-
WIN32OLE
_ VARIABLE (12) -
Zlib
:: Deflate (12) -
Zlib
:: Inflate (12)
モジュール
- Enumerable (84)
-
Net
:: HTTPHeader (24) - TSort (23)
キーワード
- * (24)
- [] (12)
-
_ _ send _ _ (24) -
abort
_ on _ exception (12) -
abort
_ on _ exception= (12) -
add
_ trace _ func (12) - alive? (12)
-
canonical
_ each (12) - chunk (12)
-
chunk
_ while (12) - deq (24)
- disjoint? (12)
-
each
_ capitalized (12) -
each
_ strongly _ connected _ component _ from (23) - empty? (6)
- fetch (8)
-
join
_ nowait (6) - load (12)
-
next
_ wait (6) -
num
_ waiting (12) -
ole
_ type _ detail (12) -
on
_ tail (12) - owned? (12)
- pack (21)
- pop (24)
- run (12)
-
set
_ dictionary (24) -
set
_ trace _ func (12) - shelljoin (12)
- shift (24)
-
slice
_ after (24) -
slice
_ before (24) -
slice
_ when (12) - split (19)
- sum (18)
-
thread
_ variable _ get (12) -
thread
_ variable _ set (12) - unlock (12)
- unpack (12)
- value (12)
- wakeup (12)
検索結果
先頭5件
-
BasicObject
# _ _ send _ _ (name , *args) -> object (13.0) -
オブジェクトのメソッド name を 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,... -
BasicObject
# _ _ send _ _ (name , *args) { . . . . } -> object (13.0) -
オブジェクトのメソッド name を 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,... -
Enumerable
# chunk {|elt| . . . } -> Enumerator (13.0) -
要素を前から順にブロックで評価し、その結果によって 要素をチャンクに分けた(グループ化した)要素を持つ Enumerator を返します。
...A[A-Z][A-Za-z0-9_]+\#/
open(filename) {|f|
f.chunk {|line| pat =~ line ? $& : :_alone }.each {|key, lines|
if key != :_alone
print lines.sort.join('')
else
print lines.join('')
end
}
}
//}
@raise RuntimeError 予約されている値を用いた場合に発生します... -
Enumerable
# slice _ before {|elt| bool } -> Enumerator (13.0) -
パターンがマッチした要素、もしくはブロックが真を返した要素から 次にマッチする手前までを チャンク化(グループ化)したものを繰り返す Enumerator を 返します。
...より簡単な例も参照)。
//emlist[][ruby]{
a = [0,2,3,4,6,7,9]
prev = a[0]
p a.slice_before {|e|
prev, prev2 = e, prev
prev2 + 1 != e
}.map {|es|
es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}"
}.join(",")
#=> "0,2-4,6,7,9"
//}
@see Enumerable#chunk, Enumerable#slice_after... -
Enumerable
# slice _ before(pattern) -> Enumerator (13.0) -
パターンがマッチした要素、もしくはブロックが真を返した要素から 次にマッチする手前までを チャンク化(グループ化)したものを繰り返す Enumerator を 返します。
...より簡単な例も参照)。
//emlist[][ruby]{
a = [0,2,3,4,6,7,9]
prev = a[0]
p a.slice_before {|e|
prev, prev2 = e, prev
prev2 + 1 != e
}.map {|es|
es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}"
}.join(",")
#=> "0,2-4,6,7,9"
//}
@see Enumerable#chunk, Enumerable#slice_after... -
String
# split(sep = $ ; , limit = 0) -> [String] (13.0) -
第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。
...列にマッチする場合は 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 だと制限なく分割... -
String
# split(sep = $ ; , limit = 0) {|s| . . . } -> self (13.0) -
第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。
...列にマッチする場合は 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 だと制限なく分割... -
String
# unpack(template) -> Array (13.0) -
Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。
...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]... -
Thread
:: Queue # deq(non _ block = false) -> object (13.0) -
キューからひとつ値を取り出します。キューが空の時、呼出元のスレッドは停止します。
...each { |r|
q.push(r)
}
th1.join
//}
//emlist[例: nonblock = true][ruby]{
require 'thread'
q = Queue.new
th1 = Thread.start do
while resource = q.pop
puts resource
end
end
[:resource1, :resource2, :resource3, nil].each { |r|
q.push(r)
}
begin
th1.join
q.pop(true)
rescue => e... -
Thread
:: Queue # pop(non _ block = false) -> object (13.0) -
キューからひとつ値を取り出します。キューが空の時、呼出元のスレッドは停止します。
...each { |r|
q.push(r)
}
th1.join
//}
//emlist[例: nonblock = true][ruby]{
require 'thread'
q = Queue.new
th1 = Thread.start do
while resource = q.pop
puts resource
end
end
[:resource1, :resource2, :resource3, nil].each { |r|
q.push(r)
}
begin
th1.join
q.pop(true)
rescue => e...