るりまサーチ

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

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. range end

検索結果

<< 1 2 3 ... > >>

KeyError#key -> object (21119.0)

KeyError の原因となったメソッド呼び出しのキーを返します。

...
Key
Error の原因となったメソッド呼び出しのキーを返します。

@raise ArgumentError キーが設定されていない時に発生します。

例:

h = Hash.new
begin
h.fetch('gumby'*20)
rescue KeyError => e
p e.message # => "key not found: \"gumbygumby...
...gumbygumbygumbygumbygumbygumbygumbygumbygumbygumbyg..."
p 'gumby'*20 == e.key # => true
end
...

ENV.each_key {|key| ... } -> self (6261.0)

key を引数としてブロックを評価します。

...key を引数としてブロックを評価します。

//emlist[][ruby]{
ENV['FOO'] = 'bar'
ENV.each_key do |key|
p "key #{key} detected" if key == 'FOO'
end

# "key FOO detected"
//}...

CSV::Row#deconstruct_keys(keys) -> Hash (6206.0)

パターンマッチに使用するヘッダの名前と値の Hash を返します。

...が文字列かつ Hash パターン でパターンマッチしたい場合はキーをシンボルに変換する必要があります。

@param keys パターンマッチに使用するヘッダの名前の配列を指定します。nil の場合は全てをパターンマッチに使用しま...
...: 2.. }
puts "all 2 or more"
in { header1: ...2, header2: 2.., header3: 2.. }
puts "first column is less than 2, and rest columns are 2 or more"
end

#=> "first column is less than 2, and rest columns are 2 or more" が出力される
//}

@see d:spec/pattern_matching#matching_non_primitive_objec...

ENV.each_key -> Enumerator (6161.0)

key を引数としてブロックを評価します。

...key を引数としてブロックを評価します。

//emlist[][ruby]{
ENV['FOO'] = 'bar'
ENV.each_key do |key|
p "key #{key} detected" if key == 'FOO'
end

# "key FOO detected"
//}...

Date#deconstruct_keys(array_of_names_or_nil) -> Hash (6118.0)

パターンマッチに使用する名前と値の Hash を返します。

...: ..7 # deconstruct_keys が使われます
puts "first Wednesday of the month"
end

#=> "first Wednesday of the month" が出力される

case d
in year: ...2022
puts "too old"
in month: ..9
puts "quarter 1-3"
in wday: 1..5, month:
puts "working day in month #{month}"
end

#=> "working day i...
...n month 10" が出力される

# クラスのチェックと組み合わせて利用することもできます
if d in Date(wday: 3, day: ..7)
puts "first Wednesday of the month"
end

//}

@see d:spec/pattern_matching#matching_non_primitive_objects...

絞り込み条件を変える

DateTime#deconstruct_keys(array_of_names_or_nil) -> Hash (6118.0)

パターンマッチに使用する名前と値の Hash を返します。

...: 1..5, hour: 10..18 # deconstruct_keys が使われます
puts "Working time"
end

#=> "Working time" が出力される

case dt
in year: ...2022
puts "too old"
in month: ..9
puts "quarter 1-3"
in wday: 1..5, month:
puts "working day in month #{month}"
end

#=> "working day in month 10" が...
...出力される

# クラスのチェックと組み合わせて利用することもできます
if dt in DateTime(wday: 1..5, hour: 10..18, day: ..7)
puts "Working time, first week of the month"
end

//}

@see d:spec/pattern_matching#matching_non_primitive_objects...

Time#deconstruct_keys(array_of_names_or_nil) -> Hash (6118.0)

パターンマッチに使用する名前と値の Hash を返します。

...: ..7 # deconstruct_keys が使われます
puts "first Wednesday of the month"
end

#=> "first Wednesday of the month" が出力される

case t
in year: ...2022
puts "too old"
in month: ..9
puts "quarter 1-3"
in wday: 1..5, month:
puts "working day in month #{month}"
end

#=> "working day i...
...n month 10" が出力される

# クラスのチェックと組み合わせて利用することもできます
if t in Time(wday: 3, day: ..7)
puts "first Wednesday of the month"
end

//}

@see d:spec/pattern_matching#matching_non_primitive_objects...

Data#deconstruct_keys(array_of_names_or_nil) -> Hash (6112.0)

self のメンバの名前と値の組を Hash で返します。

...//emlist[例][ruby]{
Measure = Data.define(:amount, :unit)

distance = Measure.new(10, 'km')
distance.deconstruct_keys(nil) # => {:amount=>10, :unit=>"km"}
distance.deconstruct_keys([:amount]) # => {:amount=>10}
//}

このメソッドは以下のようにパターンマッチで利用され...
...construct_keys を呼ぶ
puts "It is #{amount} kilometers away"
else
puts "Don't know how to handle it"
end

# "It is 10 kilometers away" が表示される

# 以下のようにも書ける
case distance
in Measure(amount:, unit: 'km')
puts "It is #{amount} kilometers away"
# ...
end

//}

@par...

Module#ruby2_keywords(method_name, ...) -> nil (6112.0)

For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.

...names, marks the method as passing keywords through
a normal argument splat. This should only be called on methods that
accept an argument splat (`*args`) but not explicit keywords or a
key
word splat. It marks the method such that if the method is called
with keyword arguments, the final hash arg...
...and that method call does not include explicit
key
words or a keyword splat, the final element is interpreted as
key
words. In other words, keywords will be passed through the method to
other methods.

This should only be used for methods that delegate keywords to another
method, and only for backward...
...aware that if this method is removed, the behavior of the
method will change so that it does not pass through keywords.

//emlist[例][ruby]{
module Mod
def foo(meth, *args, &block)
send(:"do_#{meth}", *args, &block)
end

ruby2_keywords(:foo) if respond_to?(:ruby2_keywords, true)
end

//}...

Proc#ruby2_keywords -> proc (6112.0)

Marks the proc as passing keywords through a normal argument splat. This should only be called on procs that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the proc such that if the proc is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the proc to other methods.

...Marks the proc as passing keywords through a normal argument splat. This
should only be called on procs that accept an argument splat (`*args`)
but not explicit keywords or a keyword splat. It marks the proc such
that if the proc is called with keyword arguments, the final hash
argument is marked...
..., and that
method call does not include explicit keywords or a keyword splat, the
final element is interpreted as keywords. In other words, keywords will
be passed through the proc to other methods.

This should only be used for procs that delegate keywords to another
method, and only for backwards...
...so, be aware that if this method is removed, the behavior of the
proc will change so that it does not pass through keywords.

//emlist[][ruby]{
module Mod
foo = ->(meth, *args, &block) do
send(:"do_#{meth}", *args, &block)
end

foo.ruby2_keywords if foo.respond_to?(:ruby2_keywords)
end

//}...

絞り込み条件を変える

Hash.ruby2_keywords_hash?(hash) -> bool (6106.0)

Module#ruby2_keywordsやProc#ruby2_keywordsによる ruby2_keywords フラグが設定されているかどうかを返します。

...Module#ruby2_keywordsやProc#ruby2_keywordsによる
ruby2_keywords フラグが設定されているかどうかを返します。

このメソッドはデバッグや調査、シリアライゼーションのために本当に必要な場合のために
用意されていて、普通のプログ...
...れていません。

ruby 2.7.1 で追加されたため、ruby 2.7.0 では定義されていません。

//emlist[][ruby]{
ruby2_keywords def foo(*args)
Hash.ruby2_keywords_hash?(args.last)
end

foo(k: 1) # => true
foo({k: 1}) # => false
//}

@see Module#ruby2_keywords, Proc#ruby2_keywords...

OpenSSL::PKey::RSA (3072.0)

RSA 暗号鍵のクラスです。

...このクラスで利用するのは、
OpenSSL::PKey::RSA.generate, OpenSSL::PKey::RSA.new,
OpenSSL::PKey::RSA#public?, OpenSSL::PKey::RSA#private?,
OpenSSL::PKey::RSA#public_key, OpenSSL::PKey::RSA#to_text,
OpenSSL::PKey::RSA#to_pem, OpenSSL::PKey::RSA#to_der
のいずれかでしょう。これ...
...enSSL::PKey::RSA.generate(2048)
# 秘密鍵をAES256で暗号化して private_key.pem に PEM 形式で保存
passphrase = "!secret passphrase!"
File.open("private_key.pem", "w") do |f|
f.write(rsa.export(OpenSSL::Cipher.new("aes256"), passphrase))
end

# 公開鍵をpublic_key.pemに...
...blic_key = rsa.public_key
File.open("public_key.pem", "w") do |f|
f.write(public_key.export)
end


# 秘密鍵で署名
data = "foobar"
sign = rsa.sign("sha256", data)
# 公開鍵で検証
p public_key.verify("sha256", sign, data)
# 不正なデータを検証
p public_key.ver...

KeyError#receiver -> object (3012.0)

KeyError の原因となったメソッド呼び出しのレシーバを返します。

...
Key
Error の原因となったメソッド呼び出しのレシーバを返します。

@raise ArgumentError レシーバが設定されていない時に発生します。

例:

h = Hash.new
begin
h.fetch('gumby'*20)
rescue KeyError => e
p e.message # => "key not found:...
...\"gumbygumbygumbygumbygumbygumbygumbygumbygumbygumbygumbygumbyg..."
p h.equal?(e.receiver) # => true
end
...

1.6.8から1.8.0への変更点(まとめ) (864.0)

1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))

...よくわかりません(^^;

class << Object
p [self.id, self]
class << self
p [self.id, self]
end

end

=> ruby 1.6.7 (2002-03-01) [i586-linux]
[537771634, Class]
[537742484, Class]
=> ruby 1.7.3 (2002-09...
...class << Object.new
class << self.superclass
p [self.id, self]
end

class << self
p [self.superclass.id, self.superclass]
end

end

=> ruby 1.6.7 (2002-03-01) [i586-linux]
[537771634, Class]
[5...
......」 を参照のこと)
((<ruby-dev:12670>))

: ((<SystemExit#status|SystemExit/status>)) [new]
追加

=== Thread

: ((<Thread#keys|Thread/keys>)) [new]
追加。Thread固有データのキーの配列を返します。


: ((<Thread#terminate|Thread/terminate>)) [new]

追加...
<< 1 2 3 ... > >>