クラス
- Array (24)
- DBM (11)
- Hash (28)
- Object (11)
-
OpenSSL
:: X509 :: Extension (11) - OpenStruct (17)
- SDBM (11)
モジュール
- Enumerable (24)
検索結果
先頭5件
-
OpenStruct
# to _ h -> { Symbol => object } (21115.0) -
self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返 します。
...t[例][ruby]{
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
data.to_h # => {:country => "Australia", :capital => "Canberra" }
data.to_h {|name, value| [name.to_s, value.upcase] }
# => {"country" => "AUSTRALIA", "capital" => "CANBERRA" }
//}... -
OpenStruct
# to _ h {|name , value| block } -> Hash (21115.0) -
self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返 します。
...t[例][ruby]{
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
data.to_h # => {:country => "Australia", :capital => "Canberra" }
data.to_h {|name, value| [name.to_s, value.upcase] }
# => {"country" => "AUSTRALIA", "capital" => "CANBERRA" }
//}... -
OpenStruct
# to _ h -> { Symbol => object } (21108.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 (21102.0) -
拡張領域の内容を、 { "oid" => 識別子(extnID), "value" => 値(extnValue), "critical" => 重要度(critical) } というハッシュで返します。
拡張領域の内容を、
{ "oid" => 識別子(extnID), "value" => 値(extnValue), "critical" => 重要度(critical) }
というハッシュで返します。 -
Hash
# to _ h -> self | Hash (18163.0) -
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
//}
ブロックを指定すると各ペ......アでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upcase, value-32] } # => {"A"=>65, "B"=>66}
//}
@see Enumerable#map... -
Hash
# to _ h {|key , value| block } -> Hash (18163.0) -
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
//}
ブロックを指定すると各ペ......アでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upcase, value-32] } # => {"A"=>65, "B"=>66}
//}
@see Enumerable#map... -
Hash
# to _ h -> self | Hash (18156.0) -
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 (6119.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 (6107.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 (6107.0) -
オブジェクトの Hash への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。
...すべての場面で代置可能であるような、
* ハッシュそのものとみなせるようなもの
という厳しいものになっています。
//emlist[][ruby]{
class Foo
def to_hash
{'as' => 24}
end
end
it = Foo.new
p({:as => 12}.merge(it)) #=> {"as"=>24, :as=>12}
//}... -
SDBM
# to _ hash -> Hash (6107.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"}... -
Enumerable
# map -> Enumerator (3119.0) -
各要素に対してブロックを評価した結果を全て含む配列を返します。
...配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にした配列を返す
p (1..3).map {|n| n * 3 } # => [3, 6, 9]
p (1..3).collect { "cat" } # => ["cat", "cat", "cat"]
//}
@see Hash#to_h, Array#collect, Array#map... -
Enumerable
# map {|item| . . . } -> [object] (3119.0) -
各要素に対してブロックを評価した結果を全て含む配列を返します。
...配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にした配列を返す
p (1..3).map {|n| n * 3 } # => [3, 6, 9]
p (1..3).collect { "cat" } # => ["cat", "cat", "cat"]
//}
@see Hash#to_h, Array#collect, Array#map...