220件ヒット
[1-100件を表示]
(0.071秒)
種類
- インスタンスメソッド (143)
- モジュール関数 (44)
- 特異メソッド (33)
クラス
- Array (33)
- Method (11)
- String (11)
- Thread (22)
- UnboundMethod (11)
モジュール
- Enumerable (55)
- GC (33)
- ObjectSpace (44)
検索結果
先頭5件
-
String
# count(*chars) -> Integer (18358.0) -
chars で指定された文字が文字列 self にいくつあるか数えます。
...す引数 chars の形式は tr(1) と同じです。
つまり、「"a-c"」は文字 a から c を意味し、
「"^0-9"」のように文字列の先頭が「^」の場合は
指定文字以外を意味します。
文字「-」は文字列の両端にない場合にだけ範囲指定の意味......になります。
同様に、「^」も文字列の先頭にあるときだけ否定の効果を発揮します。
また、「-」「^」「\」は
バックスラッシュ (「\」) によりエスケープできます。
引数を複数指定した場合は、
すべての引数にマッチし......文字のパターン
//emlist[例][ruby]{
p 'abcdefg'.count('c') # => 1
p '123456789'.count('2378') # => 4
p '123456789'.count('2-8', '^4-6') # => 4
# ファイルの行数を数える
n_lines = File.read("foo").count("\n")
# ファイルの末尾に改行コードがな... -
Array
# count -> Integer (18332.0) -
レシーバの要素数を返します。
...ブロックを評価して真になった要素の個数を
カウントして返します。
@param item カウント対象となる値。
//emlist[例][ruby]{
ary = [1, 2, 4, 2.0]
ary.count # => 4
ary.count(2) # => 2
ary.count{|x|x%2==0} # => 3
//}
@see Enumerable#count... -
Array
# count {|obj| . . . } -> Integer (18332.0) -
レシーバの要素数を返します。
...ブロックを評価して真になった要素の個数を
カウントして返します。
@param item カウント対象となる値。
//emlist[例][ruby]{
ary = [1, 2, 4, 2.0]
ary.count # => 4
ary.count(2) # => 2
ary.count{|x|x%2==0} # => 3
//}
@see Enumerable#count... -
Array
# count(item) -> Integer (18332.0) -
レシーバの要素数を返します。
...ブロックを評価して真になった要素の個数を
カウントして返します。
@param item カウント対象となる値。
//emlist[例][ruby]{
ary = [1, 2, 4, 2.0]
ary.count # => 4
ary.count(2) # => 2
ary.count{|x|x%2==0} # => 3
//}
@see Enumerable#count... -
Enumerable
# count -> Integer (18332.0) -
レシーバの要素数を返します。
...価して真になった要素の個数を
カウントして返します。
@param item カウント対象となる値。
//emlist[例][ruby]{
enum = [1, 2, 4, 2].each
enum.count # => 4
enum.count(2) # => 2
enum.count{|x|x%2==0} # => 3
//}
@see Array#count... -
Enumerable
# count {|obj| . . . } -> Integer (18332.0) -
レシーバの要素数を返します。
...価して真になった要素の個数を
カウントして返します。
@param item カウント対象となる値。
//emlist[例][ruby]{
enum = [1, 2, 4, 2].each
enum.count # => 4
enum.count(2) # => 2
enum.count{|x|x%2==0} # => 3
//}
@see Array#count... -
Enumerable
# count(item) -> Integer (18332.0) -
レシーバの要素数を返します。
...価して真になった要素の個数を
カウントして返します。
@param item カウント対象となる値。
//emlist[例][ruby]{
enum = [1, 2, 4, 2].each
enum.count # => 4
enum.count(2) # => 2
enum.count{|x|x%2==0} # => 3
//}
@see Array#count... -
GC
. count -> Integer (18326.0) -
プロセス開始からガーベージコレクトを実行した回数を Integer で返し ます。
...プロセス開始からガーベージコレクトを実行した回数を Integer で返し
ます。
//emlist[例][ruby]{
GC.count # => 3
//}... -
Thread
# priority -> Integer (263.0) -
スレッドの優先度を返します。この値が大きいほど優先度が高くなります。 メインスレッドのデフォルト値は 0 です。新しく生成されたスレッドは親スレッドの priority を引き継ぎます。
...][ruby]{
Thread.current.priority # => 0
count1 = count2 = 0
a = Thread.new do
loop { count1 += 1 }
end
a.priority = -1
b = Thread.new do
loop { count2 += 1 }
end
b.priority = -2
count1 = count2 = 0 # reset
sleep 1 # => 1
count1 # => 13809431
count2 # => 11571921
//}... -
ObjectSpace
. # each _ object {|object| . . . } -> Integer (252.0) -
指定された klass と Object#kind_of? の関係にある全ての オブジェクトに対して繰り返します。引数が省略された時には全てのオブ ジェクトに対して繰り返します。 繰り返した数を返します。
...を扱う][ruby]{
ObjectSpace.each_object.take(5).each { |x| p x }
count = ObjectSpace.each_object { |x| x }
puts "Total count: #{count}"
# => "scope"
# => "scopes"
# => "sym"
# => "class_names"
# => "@corrections"
# => Total count: 9938
//}
//emlist[例: 任意のクラスを扱う][ruby]{
Person......= Struct.new(:name)
s1 = Person.new("tanaka")
s2 = Person.new("sato")
count = ObjectSpace.each_object(Person) { |x| p x }
puts "Total count: #{count}"
# => #<struct Person name="sato">
# => #<struct Person name="tanaka">
# => Total count: 2
//}...