ライブラリ
クラス
- Array (47)
-
CSV
:: Row (12) - DBM (12)
- Data (6)
- GDBM (12)
- Hash (31)
-
JSON
:: State (24) - NilClass (12)
- Object (12)
-
OpenSSL
:: X509 :: Extension (12) - OpenStruct (19)
-
Rake
:: TaskArguments (12) - SDBM (12)
- Socket (24)
- Struct (19)
-
YAML
:: DBM (12)
モジュール
- Enumerable (47)
- JSON (48)
-
Socket
:: Constants (24)
オブジェクト
- ENV (43)
キーワード
-
IPPROTO
_ HELLO (24) -
IPPROTO
_ HOPOPTS (24) -
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 1 . 0 (12) -
NEWS for Ruby 2
. 6 . 0 (7) - clone (12)
- collect (28)
- generate (12)
-
is
_ pointer _ to _ heap (12) - map (28)
-
pretty
_ generate (12) -
pretty
_ unparse (12) -
rdoc
/ markup / to _ html (12) -
rdoc
/ markup / to _ html _ crossref (12) -
to
_ hash (120) - unparse (12)
検索結果
先頭5件
-
Enumerable
# to _ h(*args) -> Hash (18107.0) -
self を [key, value] のペアの配列として解析した結果を Hash にして 返します。
...self を [key, value] のペアの配列として解析した結果を Hash にして
返します。
@param args each の呼び出し時に引数として渡されます。
//emlist[例][ruby]{
%i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1}
//}... -
JSON
:: State # to _ h -> Hash (18107.0) -
自身をハッシュに変換します。
...自身をハッシュに変換します。
//emlist[例][ruby]{
require "json"
require "pp"
json_state = JSON::State.new
pp json_state.to_h
# => {:indent=>"",
# :space=>"",
# :space_before=>"",
# :object_nl=>"",
# :array_nl=>"",
# :allow_nan=>false,
# :ascii_only=>false,... -
NilClass
# to _ h -> {} (18107.0) -
{} を返します。
...{} を返します。
//emlist[例][ruby]{
nil.to_h #=> {}
//}... -
OpenStruct
# to _ h -> { Symbol => object } (18107.0) -
self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返 します。
...self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返
します。
//emlist[例][ruby]{
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
data.to_h # => {:country => "Australia", :capital => "Canberra" }
//}... -
Struct
# to _ h -> Hash (18107.0) -
self のメンバ名(Symbol)と値の組を Hash にして返します。
...して返します。
//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_h
# => {:name=>"Joe Smith", :address=>"123 Maple, Anytown NC", :zip=>12345}
//}
[注意] 本メソッドの記述は Struct の下位クラスのイ... -
ENV
. to _ h -> Hash (18101.0) -
環境変数の名前をキーとし、対応する値をもつハッシュを返します。
環境変数の名前をキーとし、対応する値をもつハッシュを返します。 -
OpenSSL
:: X509 :: Extension # to _ h -> Hash (18101.0) -
拡張領域の内容を、 { "oid" => 識別子(extnID), "value" => 値(extnValue), "critical" => 重要度(critical) } というハッシュで返します。
拡張領域の内容を、
{ "oid" => 識別子(extnID), "value" => 値(extnValue), "critical" => 重要度(critical) }
というハッシュで返します。 -
JSON
:: State # to _ hash -> Hash (6107.0) -
自身をハッシュに変換します。
...自身をハッシュに変換します。
//emlist[例][ruby]{
require "json"
require "pp"
json_state = JSON::State.new
pp json_state.to_h
# => {:indent=>"",
# :space=>"",
# :space_before=>"",
# :object_nl=>"",
# :array_nl=>"",
# :allow_nan=>false,
# :ascii_only=>false,... -
Hash
# to _ hash -> self (6106.0) -
self を返します。
...self を返します。
//emlist[例][ruby]{
hash = {}
p hash.to_hash # => {}
p hash.to_hash == hash # => true
//}
@see Object#to_hash, Hash#to_h... -
CSV
:: Row # to _ hash -> Hash (6100.0) -
自身をシンプルなハッシュに変換します。
...プルなハッシュに変換します。
フィールドの順序は無視されます。
重複したフィールドは削除されます。
//emlist[例][ruby]{
require "csv"
row = CSV::Row.new(["header2", "header1", "header2"], [1, 2, 3])
row.to_hash # => {"header2"=>3, "header1"=>2}
//}... -
DBM
# to _ hash -> Hash (6100.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"}...