種類
- インスタンスメソッド (276)
- 特異メソッド (60)
- モジュール関数 (60)
- 文書 (12)
クラス
-
CSV
:: Row (12) - DBM (24)
- GDBM (24)
- Hash (132)
-
JSON
:: State (24) - Object (12)
-
Rake
:: TaskArguments (24) - SDBM (48)
-
YAML
:: DBM (12)
オブジェクト
- ENV (24)
キーワード
- Hash (12)
-
NEWS for Ruby 2
. 0 . 0 (12) - [] (24)
- generate (12)
- merge (24)
- merge! (24)
-
pretty
_ generate (12) -
pretty
_ unparse (12) - reject (36)
- replace (36)
-
to
_ h (12) -
try
_ convert (12) - unparse (12)
- update (36)
-
with
_ defaults (12)
検索結果
先頭5件
-
YAML
:: DBM # to _ hash -> Hash (18101.0) -
自身のキー、値をハッシュにしたものを返します。
自身のキー、値をハッシュにしたものを返します。 -
JSON
:: State # to _ hash -> Hash (15101.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
# replace(other) -> self (30.0) -
ハッシュの内容を other の内容で置き換えます。
...ります。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
self = other.to_hash.dup と同じです。
@param other ハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return sel......{2 => 'B', 3 => 'C'}
foo.replace(bar)
p foo #=> {2=>"B", 3=>"C"}
zoo = {}
zoo = bar.dup
p zoo #=> {2=>"B", 3=>"C"}
class Foo
def to_hash
{:japan => 'kyoto'}
end
end
h = Hash.new
h.replace(Foo.new) #暗黙の変換
p h #=> {:japan=>"kyoto"}
//}
@see Hash#dup,Hash#merge,Object#to_hash... -
Hash
# merge(*others) -> Hash (18.0) -
selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。 デフォルト値はselfの設定のままです。
...値を使います。
othersがハッシュではない場合、othersのメソッドto_hashを使って暗黙の変換を試みます。
@param others マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結......l + bar_val }
# => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
p foo # => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
//}
//emlist[][ruby]{
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France =>... -
Hash
# merge(*others) {|key , self _ val , other _ val| . . . } -> Hash (18.0) -
selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。 デフォルト値はselfの設定のままです。
...値を使います。
othersがハッシュではない場合、othersのメソッドto_hashを使って暗黙の変換を試みます。
@param others マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結......l + bar_val }
# => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
p foo # => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
//}
//emlist[][ruby]{
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France =>... -
Hash
# merge(other) -> Hash (18.0) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...r の値を使います。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param other マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結......l + bar_val }
# => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
p foo # => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
//}
//emlist[][ruby]{
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France =>... -
Hash
# merge(other) {|key , self _ val , other _ val| . . . } -> Hash (18.0) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...r の値を使います。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param other マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結......l + bar_val }
# => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
p foo # => {1=>"a", 2=>"bB", 3=>"cC", 4=>"D"}
//}
//emlist[][ruby]{
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France =>... -
SDBM
# replace(other) -> self (18.0) -
self の内容を other の内容で置き換えます。
...p db1 #=> #<SDBM:0xb7c304d0>
p db1.to_hash #=> {"a"=>"aaa", "b"=>"bbb", "c"=>"ccc"}
p db1.replace(db2) #=> #<SDBM:0xb7c304d0>
p db1.to_hash #=> {"c"=>"ccc", "d"=>"ddd"}
p db1.replace(hash) #=> #<SDBM:0xb7c304d0>
p db1.to_hash #=> {"x"=>"xxx", "y"=>"yyy"}... -
SDBM
# update(other) -> self (18.0) -
self と other の内容をマージします。
...#=> #<SDBM:0xb7d19554>
p db1.to_hash #=> {"a"=>"aaa", "b"=>"bbb", "c"=>"ccc"}
p db1.update(db2) #=> #<SDBM:0xb7d19554>
p db1.to_hash #=> {"a"=>"aaa", "b"=>"bbb", "c"=>"ccc", "d"=>"ddd"}
p db1.update(hash) #=> #<SDBM:0xb7d19554>
p db1.to_hash #=> {"a"=>"aaa", "x"=>"xx... -
Hash
. try _ convert(obj) -> Hash | nil (16.0) -
to_hash メソッドを用いて obj をハッシュに変換しようとします。
...
to_hash メソッドを用いて obj をハッシュに変換しようとします。
何らかの理由で変換できないときには nil を返します。
このメソッドは引数がハッシュであるかどうかを調べるために使えます。
//emlist[][ruby]{
Hash.try_convert({... -
Kernel
. # Hash(arg) -> Hash (16.0) -
引数 arg で指定したオブジェクトを to_hash メソッドを呼び出す事で Hash オブジェクトに変換します。nil か [] を指定した場合は空の Hash オブジェクトを返します。
...引数 arg で指定したオブジェクトを to_hash メソッドを呼び出す事で
Hash オブジェクトに変換します。nil か [] を指定した場合は空の
Hash オブジェクトを返します。
@param arg 変換対象のオブジェクトを指定します。
//emlist[例]...