種類
- インスタンスメソッド (331)
- 特異メソッド (142)
- モジュール関数 (57)
クラス
- Data (2)
- Enumerator (44)
-
Enumerator
:: Lazy (10) - Hash (122)
- IO (110)
- Module (5)
- String (27)
- Symbol (5)
- Thread (32)
- Time (11)
モジュール
- Enumerable (105)
- Kernel (35)
- Marshal (22)
キーワード
- dump (22)
-
each
_ with _ index (22) -
each
_ with _ object (22) - exit (11)
- filter! (12)
-
keep
_ if (22) -
max
_ by (44) - new (16)
- popen (110)
-
report
_ on _ exception (16) -
report
_ on _ exception= (16) -
ruby2
_ keywords (5) - select! (22)
-
start
_ with? (16) - strftime (11)
- system (24)
-
to
_ h (17) -
transform
_ keys (17) -
transform
_ keys! (17) -
transform
_ values (16) -
transform
_ values! (16) -
with
_ index (32) -
with
_ object (22)
検索結果
先頭5件
-
Data
# with(**kwargs) -> Data (27315.0) -
self をコピーしたオブジェクトを返します。
...変わらない「浅い(shallow)」コピーを行います。
キーワード引数が指定された場合、引数に対応するメンバには引数の値が設定されます。存在しないメンバを指定した場合はエラーとなります。
@param kwargs コピーされたオブ......定します。
@raise ArgumentError 存在しないメンバを指定した場合に発生します。
//emlist[例][ruby]{
Dog = Data.define(:name, :age)
dog1 = Dog.new("Fred", 5) # => #<data Dog name="Fred", age=5>
dog2 = dog1.with(age: 6) # => #<data Dog name="Fred", age=6>
p dog1......#<data Dog name="Fred", age=5>
dog3 = dog1.with(type: "Terrier") # => ArgumentError (unknown keyword: :type)
# メンバのオブジェクトはコピーされず、同じオブジェクトを参照する。
dog1.name.upcase!
p dog1 # => #<data Dog name="FRED", age=5>
p dog2 # => #<data Dog name=... -
Enumerable
# each _ with _ index(*args) {|item , index| . . . } -> self (18446.0) -
要素とそのインデックスをブロックに渡して繰り返します。
...り返すような
Enumerator を返します。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。
@param args イテレータメソッド (each など) にそのまま......//emlist[例][ruby]{
[5, 10, 15].each_with_index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}
//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]......//}
@see Enumerator#with_index... -
Symbol
# start _ with?(*prefixes) -> bool (18351.0) -
self の先頭が prefixes のいずれかであるとき true を返します。
...先頭が prefixes のいずれかであるとき true を返します。
(self.to_s.start_with?と同じです。)
@param prefixes パターンを表す文字列または正規表現 (のリスト)
@see Symbol#end_with?
@see String#start_with?
//emlist[][ruby]{
:hello.start_with?("hell")......#=> true
:hello.start_with?(/H/i) #=> true
# returns true if one of the prefixes matches.
:hello.start_with?("heaven", "hell") #=> true
:hello.start_with?("heaven", "paradise") #=> false
//}... -
Enumerable
# each _ with _ index(*args) -> Enumerator (18346.0) -
要素とそのインデックスをブロックに渡して繰り返します。
...り返すような
Enumerator を返します。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。
@param args イテレータメソッド (each など) にそのまま......//emlist[例][ruby]{
[5, 10, 15].each_with_index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}
//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]......//}
@see Enumerator#with_index... -
Enumerable
# each _ with _ object(obj) -> Enumerator (18340.0) -
与えられた任意のオブジェクトと要素をブロックに渡し繰り返し、最初に与えられたオブジェクトを返します。
...返します。
ブロックを省略した場合は Enumerator を返します。
@param obj 任意のオブジェクトを指定します。
//emlist[例][ruby]{
evens = (1..10).each_with_object([]) {|i, a| a << i*2 }
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerator#with_object... -
Enumerable
# each _ with _ object(obj) {|(*args) , memo _ obj| . . . } -> object (18340.0) -
与えられた任意のオブジェクトと要素をブロックに渡し繰り返し、最初に与えられたオブジェクトを返します。
...返します。
ブロックを省略した場合は Enumerator を返します。
@param obj 任意のオブジェクトを指定します。
//emlist[例][ruby]{
evens = (1..10).each_with_object([]) {|i, a| a << i*2 }
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}
@see Enumerator#with_object... -
String
# start _ with?(*prefixes) -> bool (18339.0) -
self の先頭が prefixes のいずれかであるとき true を返します。
...が prefixes のいずれかであるとき true を返します。
@param prefixes パターンを表す文字列または正規表現 (のリスト)
//emlist[例][ruby]{
"string".start_with?("str") # => true
"string".start_with?("ing") # => false
"string".start_with?("ing", "st......r") # => true
"string".start_with?(/\w/) # => true
"string".start_with?(/\d/) # => false
//}
@see String#end_with?
@see String#delete_prefix, String#delete_prefix!... -
String
# start _ with?(*strs) -> bool (18327.0) -
self の先頭が strs のいずれかであるとき true を返します。
...れかであるとき true を返します。
@param strs パターンを表す文字列 (のリスト)
//emlist[例][ruby]{
"string".start_with?("str") # => true
"string".start_with?("ing") # => false
"string".start_with?("ing", "str") # => true
//}
@see String#end_with?... -
Enumerator
# with _ index(offset = 0) -> Enumerator (15340.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
...す。
//emlist[例][ruby]{
str = "xyz"
enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [120, 0]
# [121, 1]
# [122, 2]
require "stringio"
StringIO.new("foo|bar|baz").each("|").with_index(1) {|s, i| p [s, i] }
# => ["f......# ["bar|", 2]
# ["baz", 3]
//}
生成時のパラメータに従って、要素にインデックスを添えてブロックを繰り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は... -
Enumerator
# with _ index(offset = 0) {|(*args) , idx| . . . } -> object (15340.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
...す。
//emlist[例][ruby]{
str = "xyz"
enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [120, 0]
# [121, 1]
# [122, 2]
require "stringio"
StringIO.new("foo|bar|baz").each("|").with_index(1) {|s, i| p [s, i] }
# => ["f......# ["bar|", 2]
# ["baz", 3]
//}
生成時のパラメータに従って、要素にインデックスを添えてブロックを繰り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は... -
Enumerator
# with _ object(obj) -> Enumerator (15328.0) -
繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。
...を返す Enumerator を返します。
//emlist[例][ruby]{
# 0,1,2 と呼びだす enumeratorを作る
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end
to_three_with_string = to_three.with_object("foo")
to_three_with_string.each do |x,string|
puts "#{string}: #{x}"
end
#......=> foo:0
# => foo:1
# => foo:2
//}
@param obj 繰り返しの各要素に添えて渡されるオブジェクト
@see Enumerable#each_with_object... -
Enumerator
# with _ object(obj) {|(*args) , memo _ obj| . . . } -> object (15328.0) -
繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。
...を返す Enumerator を返します。
//emlist[例][ruby]{
# 0,1,2 と呼びだす enumeratorを作る
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end
to_three_with_string = to_three.with_object("foo")
to_three_with_string.each do |x,string|
puts "#{string}: #{x}"
end
#......=> foo:0
# => foo:1
# => foo:2
//}
@param obj 繰り返しの各要素に添えて渡されるオブジェクト
@see Enumerable#each_with_object...