618件ヒット
[1-100件を表示]
(0.029秒)
種類
- インスタンスメソッド (594)
- 特異メソッド (24)
キーワード
- []= (36)
- abbrev (12)
- all? (21)
- any? (30)
- bsearch (24)
-
bsearch
_ index (20) - delete (24)
- fill (72)
- filter! (14)
-
find
_ index (36) - flatten (12)
- flatten! (12)
- include? (12)
- index (36)
- insert (12)
-
keep
_ if (24) - new (12)
- pack (21)
- reject (20)
- reverse (12)
- reverse! (12)
-
reverse
_ each (24) - rindex (36)
- select! (24)
-
to
_ csv (12) -
try
_ convert (12) -
values
_ at (12) - zip (24)
検索結果
先頭5件
-
Array
# abbrev(pattern = nil) -> Hash (6101.0) -
self が文字列の配列の場合、self から一意に決まる短縮形を計算し、 短縮形をキー、元の文字列を値とするハッシュを返します。
...Abbrev.#abbrev(self, pattern) と同じです。
@param pattern Regexp か String を指定します。
require 'abbrev'
p %w[ruby rubyist].abbrev
#=> {"ruby" => "ruby",
# "rubyi" => "rubyist",
# "rubyis" => "rubyist",
# "rubyist" => "rubyist"}
@see Abbrev.#abbrev... -
Array
# reverse -> Array (6101.0) -
reverse は自身の要素を逆順に並べた新しい配列を生成して返します。 reverse! は自身を破壊的に並べ替えます。 reverse! は self を返します。
...reverse は自身の要素を逆順に並べた新しい配列を生成して返します。
reverse! は自身を破壊的に並べ替えます。
reverse! は self を返します。
//emlist[例][ruby]{
a = ["a", 2, true]
p a.reverse #=> [true, 2, "a"]
p a #=> ["a", 2, t......rue] (変化なし)
a = ["a", 2, true]
p a.reverse! #=> [true, 2, "a"]
p a #=> [true, 2, "a"]
//}... -
Array
# reverse! -> self (6101.0) -
reverse は自身の要素を逆順に並べた新しい配列を生成して返します。 reverse! は自身を破壊的に並べ替えます。 reverse! は self を返します。
...reverse は自身の要素を逆順に並べた新しい配列を生成して返します。
reverse! は自身を破壊的に並べ替えます。
reverse! は self を返します。
//emlist[例][ruby]{
a = ["a", 2, true]
p a.reverse #=> [true, 2, "a"]
p a #=> ["a", 2, t......rue] (変化なし)
a = ["a", 2, true]
p a.reverse! #=> [true, 2, "a"]
p a #=> [true, 2, "a"]
//}... -
Array
# reverse _ each -> Enumerator (6101.0) -
各要素に対して逆順にブロックを評価します。
...て逆順にブロックを評価します。
ブロックが与えられなかった場合は、自身と reverse_each から生成した
Enumerator オブジェクトを返します。
//emlist[例][ruby]{
a = [ "a", "b", "c" ]
a.reverse_each {|x| print x, " " }
# => c b a
//}
@see Array#each... -
Array
# reverse _ each {|item| . . . } -> self (6101.0) -
各要素に対して逆順にブロックを評価します。
...て逆順にブロックを評価します。
ブロックが与えられなかった場合は、自身と reverse_each から生成した
Enumerator オブジェクトを返します。
//emlist[例][ruby]{
a = [ "a", "b", "c" ]
a.reverse_each {|x| print x, " " }
# => c b a
//}
@see Array#each... -
Array
# to _ csv(**options) -> String (6101.0) -
CSV.generate_line(self, options) と同様です。
...CSV.generate_line(self, options) と同様です。
Array オブジェクトを 1 行の CSV 文字列に変換するためのショートカットです。
@param options CSV.generate_line と同様のオプションを指定します。
//emlist[][ruby]{
require 'csv'
p [1, 'Matz', :Ruby, Dat......e.new(1965, 4, 14)].to_csv # => "1,Matz,Ruby,1965-04-14\n"
p [1, 'Matz', :Ruby, Date.new(1965, 4, 14)].to_csv(col_sep: ' ', row_sep: "\r\n") # => "1 Matz Ruby 1965-04-14\r\n"
//}
@see CSV.generate_line......e.new(1965, 4, 14)].to_csv # => "1,Matz,Ruby,1965-04-14\n"
p [1, 'Matz', :Ruby, Date.new(1965, 4, 14)].to_csv(col_sep: ' ', row_sep: "\r\n") # => "1 Matz Ruby 1965-04-14\r\n"
//}
Ruby 3.0 (CSV 3.1.9) から、次のオプションが使えるようになりました....../emlist[][ruby]{
require 'csv'
puts [1, nil].to_csv # => 1,
puts [1, nil].to_csv(write_nil_value: "N/A") # => 1,N/A
puts [2, ""].to_csv # => 2,""
puts [2, ""].to_csv(write_empty_value: "BLANK") # => 2,BLANK
//}
@see CSV.generate_line... -
Array
# values _ at(*selectors) -> Array (6101.0) -
引数で指定されたインデックスに対応する要素を配列で返します。インデッ クスに対応する値がなければ nil が要素になります。
...ary.values_at( 0, 2, 4 ) #=> ["a", "c", "e"]
p ary.values_at( 3, 4, 5, 6, 35 ) #=> ["d", "e", nil, nil, nil]
p ary.values_at( 0, -1, -2 ) #=> ["a", "e", "d"]
p ary.values_at( -4, -5, -6, -35 ) #=> ["b", "a", nil, nil]
p ary.values_at( 1..2 ) #=> ["b", "c"]
p ary.value......s_at( 3..10 ) #=> ["d", "e", nil, nil, nil, nil, nil, nil]
p ary.values_at( 6..7 ) #=> [nil, nil]
p ary.values_at( 0, 3..5 ) #=> ["a", "d", "e", nil]
//}... -
Array
. try _ convert(obj) -> Array | nil (6101.0) -
to_ary メソッドを用いて obj を配列に変換しようとします。
...引数が配列であるかどうかを調べるために使えます。
//emlist[例][ruby]{
Array.try_convert([1]) # => [1]
Array.try_convert("1") # => nil
if tmp = Array.try_convert(arg)
# the argument is an array
elsif tmp = String.try_convert(arg)
# the argument is a string
end
//}... -
Array
# pack(template) -> String (145.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
...template 自身のバイナリとしてパックするためのテンプレートを文字列で指定します。
以下にあげるものは、Array#pack、String#unpack
のテンプレート文字の一覧です。テンプレート文字は後に「長さ」を表す数字
を続けること......システム依存の short, long のサイズにすることもできます。
i, I (int)のサイズは常にシステム依存であり、n, N, v, V
のサイズは常にシステム依存ではない(!をつけられない)ことに注意してください。
つまり、IO#ioctl などで C......ネットワークプロトコルやファイルフォーマットのように、
システムに依存しないデータを扱うときには
n, N, v, V を用います。
強制的にエンディアンを指定したいときは、
リトルエンディアンなら < を、
ビッグエンディ......ます。
指定した場合は返値も指定した文字列オブジェクトになります。
以下にあげるものは、Array#pack、String#unpack、String#unpack1
のテンプレート文字の一覧です。テンプレート文字は後に「長さ」を表す数字
を...