るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

キーワード

検索結果

String#split(sep = $;, limit = 0) -> [String] (26230.0)

第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。

...列に含まれます。

第 2 引数 limit は以下のいずれかです。

: limit > 0
最大 limit 個の文字列に分割する
: limit == 0
分割個数制限はなしで、配列末尾の空文字列を取り除く
: limit < 0
分割個数の制限はなし

@param sep...
...][ruby]{
p " a \t b \n c".split(/\s+/) # => ["", "a", "b", "c"]

p " a \t b \n c".split(nil) # => ["a", "b", "c"]
p " a \t b \n c".split(' ') # => ["a", "b", "c"] # split(nil) と同じ
p " a \t b \n c".split # => ["a", "b", "c"] # split(nil) と同じ
//}

//emlist[...
...'.split(/([-,])/) # => ["1", "-", "10", ",", "20"]
//}

//emlist[正規表現が空文字列にマッチする場合は 1 文字に分割][ruby]{
p 'hi there'.split(/\s*/).join(':') # => "h:i:t:h:e:r:e"
//}

//emlist[文字列全体を 1 文字ずつに分割する例][ruby]{
p 'hi there'.split(/...

String#split(sep = $;, limit = 0) {|s| ... } -> self (26230.0)

第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。

...列に含まれます。

第 2 引数 limit は以下のいずれかです。

: limit > 0
最大 limit 個の文字列に分割する
: limit == 0
分割個数制限はなしで、配列末尾の空文字列を取り除く
: limit < 0
分割個数の制限はなし

@param sep...
...][ruby]{
p " a \t b \n c".split(/\s+/) # => ["", "a", "b", "c"]

p " a \t b \n c".split(nil) # => ["a", "b", "c"]
p " a \t b \n c".split(' ') # => ["a", "b", "c"] # split(nil) と同じ
p " a \t b \n c".split # => ["a", "b", "c"] # split(nil) と同じ
//}

//emlist[...
...'.split(/([-,])/) # => ["1", "-", "10", ",", "20"]
//}

//emlist[正規表現が空文字列にマッチする場合は 1 文字に分割][ruby]{
p 'hi there'.split(/\s*/).join(':') # => "h:i:t:h:e:r:e"
//}

//emlist[文字列全体を 1 文字ずつに分割する例][ruby]{
p 'hi there'.split(/...

String#split(sep = $;, limit = 0) -> [String] (26229.0)

第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。

...列に含まれます。

第 2 引数 limit は以下のいずれかです。

: limit > 0
最大 limit 個の文字列に分割する
: limit == 0
分割個数制限はなしで、配列末尾の空文字列を取り除く
: limit < 0
分割個数の制限はなし

@param sep...
...][ruby]{
p " a \t b \n c".split(/\s+/) # => ["", "a", "b", "c"]

p " a \t b \n c".split(nil) # => ["a", "b", "c"]
p " a \t b \n c".split(' ') # => ["a", "b", "c"] # split(nil) と同じ
p " a \t b \n c".split # => ["a", "b", "c"] # split(nil) と同じ
//}

//emlist[...
...'.split(/([-,])/) # => ["1", "-", "10", ",", "20"]
//}

//emlist[正規表現が空文字列にマッチする場合は 1 文字に分割][ruby]{
p 'hi there'.split(/\s*/).join(':') # => "h:i:t:h:e:r:e"
//}

//emlist[文字列全体を 1 文字ずつに分割する例][ruby]{
p 'hi there'.split(/...

Array#pack(template) -> String (8086.0)

配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。

...されます。
また、`#' から改行あるいはテンプレート文字列の最後まではコメントとみな
され無視されます。

==
= 整数のテンプレート文字のシステム依存性

各テンプレート文字の説明の中で、
short や long はシステムによら...
...nsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}

==
= 各テンプレート文字の説明

説明中、Array#pack と String#unpack で違いのあるものは `/' で区切って
「Array#pack の...
...//emlist[][ruby]{
[""].pack("m") # => ""
["\0"].pack("m") # => "AA==\n"
["\0\0"].pack("m") # => "AAA=\n"
["\0\0\0"].pack("m") # => "AAAA\n"
["\xFF"].pack("m") # => "/w==\n"
["\xFF\xFF"].pack("m") # => "//8=\n"
["\xFF\xFF\xFF"].pack("m") # => "////\n"...

Array#pack(template, buffer: String.new) -> String (8086.0)

配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。

...されます。
また、`#' から改行あるいはテンプレート文字列の最後まではコメントとみな
され無視されます。

==
= 整数のテンプレート文字のシステム依存性

各テンプレート文字の説明の中で、
short や long はシステムによら...
...nsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}

==
= 各テンプレート文字の説明

説明中、Array#pack と String#unpack で違いのあるものは `/' で区切って
「Array#pack の...
...//emlist[][ruby]{
[""].pack("m") # => ""
["\0"].pack("m") # => "AA==\n"
["\0\0"].pack("m") # => "AAA=\n"
["\0\0\0"].pack("m") # => "AAAA\n"
["\xFF"].pack("m") # => "/w==\n"
["\xFF\xFF"].pack("m") # => "//8=\n"
["\xFF\xFF\xFF"].pack("m") # => "////\n"...

絞り込み条件を変える

String#unpack(template) -> Array (8086.0)

Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。

...されます。
また、`#' から改行あるいはテンプレート文字列の最後まではコメントとみな
され無視されます。

==
= 整数のテンプレート文字のシステム依存性

各テンプレート文字の説明の中で、
short や long はシステムによら...
...nsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}

==
= 各テンプレート文字の説明

説明中、Array#pack と String#unpack で違いのあるものは `/' で区切って
「Array#pack の...
...//emlist[][ruby]{
[""].pack("m") # => ""
["\0"].pack("m") # => "AA==\n"
["\0\0"].pack("m") # => "AAA=\n"
["\0\0\0"].pack("m") # => "AAAA\n"
["\xFF"].pack("m") # => "/w==\n"
["\xFF\xFF"].pack("m") # => "//8=\n"
["\xFF\xFF\xFF"].pack("m") # => "////\n"...

Thread::ConditionVariable (8038.0)

スレッドの同期機構の一つである状態変数を実現するクラスです。

...

以下も ConditionVariable を理解するのに参考になります。

https://ruby-doc.com/docs/ProgrammingRuby/html/tut_threads.html#UF

==
= Condition Variable とは

あるスレッド A が排他領域で動いていたとします。スレッド A は現在空いていない
リソー...
...hronize{
@full.wait(@mutex) if count == @max
@q.push v
@empty.signal if count == 1
}
end

def deq
@mutex.synchronize{
@empty.wait(@mutex) if count == 0
v = @q.shift
@full.signal if count == (@max - 1)
v
}
end...
...alias send enq
alias recv deq
end

if __FILE__ == $0
q = TinyQueue.new(1)
foods = 'Apple Banana Strawberry Udon Rice Milk'.split
l = []

th = Thread.new {
for obj in foods
q.send(obj)
print "sent ", obj, "\n"
end
q.send nil
}

l.push...

Enumerator::Lazy (8020.0)

map や select などのメソッドの遅延評価版を提供するためのクラス。

...
# 巨大な配列を確保しようとしてメモリを使い切ったりはしない
open("log.txt"){|f|
f.each_line.lazy.map{|line|
Hash[line.split(/\t/).map{|s| s.split(/:/, 2)}]
}.select{|hash|
hash["req"] =~ /GET/ && hash["status"] == "200"
}.each{|hash|
p hash
}
}
//}...