るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

モジュール

オブジェクト

キーワード

検索結果

<< 1 2 3 > >>

Object#to_hash -> Hash (27106.0)

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

...
デフォルトでは定義されていません。

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

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

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

it = Foo.new
p({:as => 12}.merge(it)) #=> {"as"=>24, :as=>12}
//}...

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

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

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


//emlist[例][ruby]{
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
data.to_h # => {:country => "Australia", :capital => "Canberra" }
//}...
...emlist[例][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 (18115.0)

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

...emlist[例][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" }...

JSON::State#to_h -> Hash (18113.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,
# :max_nesting=>100,
#...

JSON::State#to_hash -> Hash (6113.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,
# :max_nesting=>100,
#...

絞り込み条件を変える

Hash#to_hash -> self (6112.0)

self を返します。

...self を返します。

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

@see Object#to_hash, Hash#to_h...

JSON.#generate(object, state = nil) -> String (126.0)

与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。

...もありません。

unparse は将来削除される予定です。

@param object JSON 形式の文字列に変換するオブジェクトを指定します。

@param state JSON::State または、to_hash や to_h メソッドでハッシュに変換可能なオブジェクトを指定できま...
...ter, a : or , delimiter (default: '')
: :space_before
a string that is put before a : pair delimiter (default: '')
: :object_nl
a string that is put at the end of a JSON object (default: '')
: :array_nl
a string that is put at the end of a JSON array (default: '')
: :check_circular
真を指...

JSON.#unparse(object, state = nil) -> String (126.0)

与えられたオブジェクトを一行の JSON 形式の文字列に変換して返します。

...もありません。

unparse は将来削除される予定です。

@param object JSON 形式の文字列に変換するオブジェクトを指定します。

@param state JSON::State または、to_hash や to_h メソッドでハッシュに変換可能なオブジェクトを指定できま...
...ter, a : or , delimiter (default: '')
: :space_before
a string that is put before a : pair delimiter (default: '')
: :object_nl
a string that is put at the end of a JSON object (default: '')
: :array_nl
a string that is put at the end of a JSON array (default: '')
: :check_circular
真を指...

ENV.clone(freeze: true) -> object (119.0)

ENV オブジェクトの複製を作成して返します。

...3.1 からは複製で環境変数を操作するときに deprecated 警告がでます。

テスト実行中に環境変数を退避する用途には ENV.to_h を使用してください。

//emlist[][ruby]{
saved_env = ENV.to_h
# (テストなど)
ENV.replace(saved_env)
//}

@see Object#clone...
...複製で環境変数を操作するときに deprecated 警告がでます。

テスト実行中に環境変数を退避する用途には ENV.to_h を使用してください。

//emlist[][ruby]{
saved_env = ENV.to_h
# (テストなど)
ENV.replace(saved_env)
//}

@see Object#clone
@see ENV.dup...
<< 1 2 3 > >>