183件ヒット
[1-100件を表示]
(0.036秒)
別のキーワード
種類
- インスタンスメソッド (123)
- モジュール関数 (48)
- 特異メソッド (12)
クラス
- Array (28)
- Hash (12)
-
JSON
:: State (24) - Object (12)
- OpenStruct (19)
モジュール
- Enumerable (28)
- JSON (48)
オブジェクト
- ENV (12)
キーワード
- clone (12)
- collect (28)
- generate (12)
- map (28)
-
pretty
_ generate (12) -
pretty
_ unparse (12) -
to
_ hash (36) - unparse (12)
検索結果
先頭5件
-
OpenStruct
# to _ h -> { Symbol => object } (18415.0) -
self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返 します。
...self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返
します。
//emlist[例][ruby]{
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :capital => "Canberra")
data.to_h # => {:country => "Australia", :capital => "Canberra" }
//}......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 (18215.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" }
//}... -
JSON
:: State # to _ h -> Hash (18213.0) -
自身をハッシュに変換します。
...quire "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,
# :depth=>0,
# :buffer_initial_length=>1024}
//}... -
Object
# to _ hash -> Hash (15206.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}
//}... -
JSON
:: State # to _ hash -> Hash (6213.0) -
自身をハッシュに変換します。
...quire "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,
# :depth=>0,
# :buffer_initial_length=>1024}
//}... -
Hash
# to _ hash -> self (6212.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 (226.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
真を指......by]{
require "json"
JSON.generate([1, 2, { name: "tanaka", age: 19 }])
# => "[1,2,{\"name\":\"tanaka\",\"age\":19}]"
json_state = JSON::State.new(space: " ")
JSON.generate([1, 2, { name: "tanaka", age: 19 }], json_state)
# => "[1,2,{\"name\": \"tanaka\",\"age\": 19}]"
//}
@see JSON::State, JSON.#p... -
JSON
. # unparse(object , state = nil) -> String (226.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
真を指......by]{
require "json"
JSON.generate([1, 2, { name: "tanaka", age: 19 }])
# => "[1,2,{\"name\":\"tanaka\",\"age\":19}]"
json_state = JSON::State.new(space: " ")
JSON.generate([1, 2, { name: "tanaka", age: 19 }], json_state)
# => "[1,2,{\"name\": \"tanaka\",\"age\": 19}]"
//}
@see JSON::State, JSON.#p... -
ENV
. clone(freeze: true) -> object (219.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...