るりまサーチ

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

別のキーワード

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

クラス

モジュール

キーワード

検索結果

<< 1 2 3 > >>

Data#with(**kwargs) -> Data (26131.0)

self をコピーしたオブジェクトを返します。

...
self
をコピーしたオブジェクトを返します。

値オブジェクトのメンバのオブジェクトはコピーされません。つまり参照しているオブジェクトが変わらない「浅い(shallow)」コピーを行います。

キーワード引数が指定された...
...me, :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)

# メンバのオブ...

Enumerable#each_with_index(*args) {|item, index| ... } -> self (14235.0)

要素とそのインデックスをブロックに渡して繰り返します。

...た場合は、
要素とそのインデックスを繰り返すような
Enumerator を返します。

Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。

@param args...
...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 (14167.0)

self の先頭が prefixes のいずれかであるとき true を返します。

...
self
の先頭が prefixes のいずれかであるとき true を返します。

(self.to_s.start_with?と同じです。)

@param prefixes パターンを表す文字列または正規表現 (のリスト)

@see Symbol#end_with?

@see String#start_with?

//emlist[][ruby]{
:hello.start_with?("hel...
...l") #=> 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
//}...

Symbol#end_with?(*suffixes) -> bool (14161.0)

self の末尾が suffixes のいずれかであるとき true を返します。

...
self
の末尾が suffixes のいずれかであるとき true を返します。

(self.to_s.end_with?と同じです。)

@param suffixes パターンを表す文字列 (のリスト)

@see Symbol#start_with?

@see String#end_with?

//emlist[][ruby]{
:hello.end_with?("ello") #=> tru...
...e

# returns true if one of the +suffixes+ matches.
:hello.end_with?("heaven", "ello") #=> true
:hello.end_with?("heaven", "paradise") #=> false
//}...

String#start_with?(*prefixes) -> bool (14155.0)

self の先頭が prefixes のいずれかであるとき true を返します。

...
self
の先頭が prefixes のいずれかであるとき true を返します。

@param prefixes パターンを表す文字列または正規表現 (のリスト)

//emlist[例][ruby]{
"string".start_with?("str") # => true
"string".start_with?("ing") # => false
"string".start_w...
...ith?("ing", "str") # => true
"string".start_with?(/\w/) # => true
"string".start_with?(/\d/) # => false
//}

@see String#end_with?
@see String#delete_prefix, String#delete_prefix!...

絞り込み条件を変える

String#end_with?(*strs) -> bool (14143.0)

self の末尾が strs のいずれかであるとき true を返します。

...
self
の末尾が strs のいずれかであるとき true を返します。

@param strs パターンを表す文字列 (のリスト)

//emlist[例][ruby]{
"string".end_with?("ing") # => true
"string".end_with?("str") # => false
"string".end_with?("str", "ing") # => true
/...
.../}

@see String#start_with?...
.../}

@see String#start_with?
@see String#delete_suffix, String#delete_suffix!...

String#start_with?(*strs) -> bool (14143.0)

self の先頭が strs のいずれかであるとき true を返します。

...
self
の先頭が strs のいずれかであるとき 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?...

Enumerable#each_with_index(*args) -> Enumerator (14135.0)

要素とそのインデックスをブロックに渡して繰り返します。

...た場合は、
要素とそのインデックスを繰り返すような
Enumerator を返します。

Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。

@param args...
...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...

Hash#filter! {|key, value| ... } -> self | nil (8139.0)

キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。

...数としてブロックを評価した結果が真であるような要素を self
に残します。

keep_if は常に self を返します。
filter! と select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。

ブロックが与え...
...合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。

//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }

h2 = h1.dup
h1.select! # => #<Enumerator: {0=>"a", 1=>"b", 2=>"c", 3=>"d", 4=>"e", 5=>"f", 6=>"g"}:select!>

h1.select! {...

Hash#keep_if {|key, value| ... } -> self (8139.0)

キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。

...数としてブロックを評価した結果が真であるような要素を self
に残します。

keep_if は常に self を返します。
filter! と select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。

ブロックが与え...
...合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。

//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }

h2 = h1.dup
h1.select! # => #<Enumerator: {0=>"a", 1=>"b", 2=>"c", 3=>"d", 4=>"e", 5=>"f", 6=>"g"}:select!>

h1.select! {...

絞り込み条件を変える

Hash#select! {|key, value| ... } -> self | nil (8139.0)

キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。

...数としてブロックを評価した結果が真であるような要素を self
に残します。

keep_if は常に self を返します。
filter! と select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。

ブロックが与え...
...合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。

//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }

h2 = h1.dup
h1.select! # => #<Enumerator: {0=>"a", 1=>"b", 2=>"c", 3=>"d", 4=>"e", 5=>"f", 6=>"g"}:select!>

h1.select! {...

Hash#keep_if {|key, value| ... } -> self (8138.0)

キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。

...を引数としてブロックを評価した結果が真であるような要素を self
に残します。

keep_if は常に self を返します。
select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。

ブロックが与えられ...
...合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。

//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }

h2 = h1.dup
h1.select! # => #<Enumerator: {0=>"a", 1=>"b", 2=>"c", 3=>"d", 4=>"e", 5=>"f", 6=>"g"}:select!>

h1.select! {...

Hash#select! {|key, value| ... } -> self | nil (8138.0)

キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。

...を引数としてブロックを評価した結果が真であるような要素を self
に残します。

keep_if は常に self を返します。
select! はオブジェクトが変更された場合に self を、
されていない場合に nil を返します。

ブロックが与えられ...
...合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。

//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }

h2 = h1.dup
h1.select! # => #<Enumerator: {0=>"a", 1=>"b", 2=>"c", 3=>"d", 4=>"e", 5=>"f", 6=>"g"}:select!>

h1.select! {...

String#delete_prefix!(prefix) -> self | nil (8131.0)

self の先頭から破壊的に prefix を削除します。

...self の先頭から破壊的に prefix を削除します。

@param prefix 先頭から削除する文字列を指定します。

@return 削除した場合は self、変化しなかった場合は nil

//emlist[][ruby]{
"hello".delete_prefix!("hel") # => "lo"
"hello".delete_prefix!("llo") # => n...
...il
//}

@see String#delete_prefix
@see String#delete_suffix!
@see String#start_with?...

String#delete_suffix!(suffix) -> self | nil (8131.0)

self の末尾から破壊的に suffix を削除します。

...self の末尾から破壊的に suffix を削除します。

@param suffix 末尾から削除する文字列を指定します。

@return 削除した場合は self、変化しなかった場合は nil

//emlist[][ruby]{
"hello".delete_suffix!("llo") # => "he"
"hello".delete_suffix!("hel") # => n...
...il
//}

@see String#chomp!
@see String#chop!
@see String#delete_prefix!
@see String#delete_suffix
@see String#end_with?...

絞り込み条件を変える

Hash#transform_keys! {|key| ... } -> self (8116.0)

すべてのキーに対してブロックを呼び出した結果でハッシュのキーを変更します。 値は変化しません。

...ん。

@param hash 置き換え前のキーから置き換え後のキーへのハッシュを指定します。
@return transform_keys! は常に self を返します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを
返します。


//emlist[...
...c"=>3}
h.transform_keys!(&:to_sym) # => {:a=>1, :b=>2, :c=>3}
h.transform_keys!(a: "a", d: "d") # => {"a"=>1, :b=>2, :c=>3}
h.transform_keys!.with_index {|k, i| "#{k}.#{i}" }
# => {"a.0"=>1, "b.1"=>2, "c.2"=>3}
//}

@see Hash#transform_keys
@see Hash#transform...
<< 1 2 3 > >>