るりまサーチ (Ruby 2.1.0)

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

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

ライブラリ

クラス

検索結果

OpenStruct#to_h -> { Symbol => object } (63325.0)

self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返 します。

self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返
します。


//emlist[例][ruby]{
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
data.to_h # => {:country => "Australia", :capital => "Canberra" }
//}

OpenSSL::X509::Extension#to_h -> Hash (63307.0)

拡張領域の内容を、 { "oid" => 識別子(extnID), "value" => 値(extnValue), "critical" => 重要度(critical) } というハッシュで返します。

拡張領域の内容を、
{ "oid" => 識別子(extnID), "value" => 値(extnValue), "critical" => 重要度(critical) }
というハッシュで返します。

Hash#to_h -> self | Hash (54469.0)

self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。

self を返します。Hash クラスのサブクラスから呼び出した場合は
self を Hash オブジェクトに変換します。

//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true

class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.class # => MyHash
p my_hash.to_h.class # => Hash
//}

Hash#to_hash -> self (18358.0)

self を返します。

self を返します。

//emlist[例][ruby]{
hash = {}
p hash.to_hash # => {}
p hash.to_hash == hash # => true
//}

@see Object#to_hash, Hash#to_h

DBM#to_hash -> Hash (18322.0)

self をハッシュに変換して返します。

self をハッシュに変換して返します。

require 'dbm'

db1 = DBM.open('aaa.db', 0666, DBM::NEWDB)
db1[:a] = 'aaa'
db1[:b] = 'bbbbbb'
p db1.to_hash #=> {"a"=>"aaa", "b"=>"bbbbbb"}

絞り込み条件を変える

Object#to_hash -> Hash (18322.0)

オブジェクトの Hash への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。

オブジェクトの Hash への暗黙の変換が必要なときに内部で呼ばれます。
デフォルトでは定義されていません。

説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
必要に応じてサブクラスで定義すべきものです。

このメソッドを定義する条件は、
* ハッシュが使われるすべての場面で代置可能であるような、
* ハッシュそのものとみなせるようなもの
という厳しいものになっています。

//emlist[][ruby]{
class Foo
def to_hash
{'as' => 24}
end
end

it = Foo...

SDBM#to_hash -> Hash (18322.0)

self の各要素を格納したハッシュを返します。

self の各要素を格納したハッシュを返します。

require 'sdbm'

db1 = SDBM.open('aaa.gdbm', 0666)
db1.clear
db1['a'] = 'aaa'
db1['b'] = 'bbb'
db1['c'] = 'ccc'

p db1.to_hash #=> {"a"=>"aaa", "b"=>"bbb", "c"=>"ccc"}