種類
- インスタンスメソッド (99)
- モジュール関数 (22)
- 特異メソッド (22)
- 文書 (11)
クラス
-
CSV
:: Row (11) - Hash (55)
-
JSON
:: State (22) - Object (11)
-
Rake
:: TaskArguments (22)
モジュール
- JSON (22)
キーワード
-
NEWS for Ruby 2
. 0 . 0 (11) - [] (22)
- generate (11)
- merge (22)
- replace (11)
-
to
_ h (11) - unparse (11)
-
with
_ defaults (11)
検索結果
先頭5件
-
NEWS for Ruby 2
. 0 . 0 (26048.0) -
NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...NEWS for Ruby 2.0.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス......めのメソッドです
* 拡張: Enumerator.new サイズの遅延評価のための引数を一つ受け取るようになりました
* 新規クラス: Enumerator::Lazy 遅延列挙用のクラス
* ENV
* ENV.to_h は ENV.to_hash へのエイリアスです
* Fiber
* 非......rror を発生させます
* Time
* 返り値変更:
* Time#to_s now returns US-ASCII encoding instead of BINARY.
* TracePoint
* new class. This class is replacement of set_trace_func.
Easy to use and efficient implementation.
* toplevel
* added method:
* added... -
CSV
:: Row # to _ hash -> Hash (18113.0) -
自身をシンプルなハッシュに変換します。
...プルなハッシュに変換します。
フィールドの順序は無視されます。
重複したフィールドは削除されます。
//emlist[例][ruby]{
require "csv"
row = CSV::Row.new(["header2", "header1", "header2"], [1, 2, 3])
row.to_hash # => {"header2"=>3, "header1"=>2}
//}... -
Object
# to _ hash -> Hash (18113.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}
//}... -
Rake
:: TaskArguments # to _ hash -> Hash (18113.0) -
パラメータ名と対応する値を格納したハッシュを返します。
...納したハッシュを返します。
//emlist[][ruby]{
# Rakefile での記載例とする
task default: :test_rake_app
task :test_rake_app do
arguments = Rake::TaskArguments.new(["name1", "name2"], ["value1", "value2"])
arguments.to_hash # => {:name1=>"value1", :name2=>"value2"}
end
//}... -
JSON
:: State # to _ hash -> Hash (15107.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
# replace(other) -> self (42.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 (24.0) -
selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。 デフォルト値はselfの設定のままです。
...値を使います。
othersがハッシュではない場合、othersのメソッドto_hashを使って暗黙の変換を試みます。
@param others マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結......1.merge(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1.merge(h2) {|key, oldval, newval| newval - oldval}
#=> {"a"=>100, "b"=>46, "c"=>300}
h1.merge(h2, h3) {|key, oldval, newval| newval - oldval}
#=> {"a"=>100, "b"=>311, "c"=>300, "d"=>400}
h1......, 4=>"D"}
//}
//emlist[][ruby]{
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France => 'Paris'
}
# 暗黙の変換
p h.merge(Foo.new) # => {:Germany=>"Berlin", :Australia=>"Sydney... -
Hash
# merge(*others) {|key , self _ val , other _ val| . . . } -> Hash (24.0) -
selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。 デフォルト値はselfの設定のままです。
...値を使います。
othersがハッシュではない場合、othersのメソッドto_hashを使って暗黙の変換を試みます。
@param others マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結......1.merge(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1.merge(h2) {|key, oldval, newval| newval - oldval}
#=> {"a"=>100, "b"=>46, "c"=>300}
h1.merge(h2, h3) {|key, oldval, newval| newval - oldval}
#=> {"a"=>100, "b"=>311, "c"=>300, "d"=>400}
h1......, 4=>"D"}
//}
//emlist[][ruby]{
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France => 'Paris'
}
# 暗黙の変換
p h.merge(Foo.new) # => {:Germany=>"Berlin", :Australia=>"Sydney... -
Hash
# merge(other) -> Hash (24.0) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...r の値を使います。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param other マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結......"b" => 254, "c" => 300 }
h1.merge() # => {"a"=>100, "b"=>200}
h1.merge(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1.merge(h2){|key, oldval, newval| newval - oldval}
# => {"a"=>100, "b"=>54, "c"=>300}
h1 # => {"a"=>100, "b"=>200}
//}
//emlist[][ruby]{
foo = {1 => 'a'......, 4=>"D"}
//}
//emlist[][ruby]{
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France => 'Paris'
}
# 暗黙の変換
p h.merge(Foo.new) # => {:Germany=>"Berlin", :Australia=>"Sydney... -
Hash
# merge(other) {|key , self _ val , other _ val| . . . } -> Hash (24.0) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...r の値を使います。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param other マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結......"b" => 254, "c" => 300 }
h1.merge() # => {"a"=>100, "b"=>200}
h1.merge(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1.merge(h2){|key, oldval, newval| newval - oldval}
# => {"a"=>100, "b"=>54, "c"=>300}
h1 # => {"a"=>100, "b"=>200}
//}
//emlist[][ruby]{
foo = {1 => 'a'......, 4=>"D"}
//}
//emlist[][ruby]{
class Foo
def to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France => 'Paris'
}
# 暗黙の変換
p h.merge(Foo.new) # => {:Germany=>"Berlin", :Australia=>"Sydney... -
Rake
:: TaskArguments # with _ defaults(defaults) -> Hash (18.0) -
パラメータにデフォルト値をセットします。
....new(["name1", "name2"], ["value1", "value2"])
arguments.to_hash # => {:name1=>"value1", :name2=>"value2"}
arguments.with_defaults({ default_key: "default_value"}) # => {:default_key=>"default_value", :name1=>"value1", :name2=>"value2"}
arguments.to_hash... -
Hash
. [](other) -> Hash (13.0) -
新しいハッシュを生成します。 引数otherと同一のキーと値を持つ新たなハッシュを生成して返します。
...一のキーと値を持つ新たなハッシュを生成して返します。
引数otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
デフォルト値はコピーしません。生成されたハッシュのデフォルト値は ni......キーや値に破壊的操作を行うともう片方にも影響します。
@param other 生成元となるハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
//emlist[][ruby]{
h = {1 => "value"}
h.default = "none"
g = Hash[h]
p g #=> {1=>"val...