ライブラリ
- ビルトイン (459)
- coverage (24)
- csv (135)
- date (4)
- forwardable (24)
- json (60)
-
json
/ add / exception (12) -
net
/ http (36) - pstore (36)
- rake (24)
- rbconfig (12)
-
rubygems
/ commands / dependency _ command (12) -
rubygems
/ dependency _ installer (12) -
rubygems
/ dependency _ list (12) - tsort (93)
- win32ole (12)
クラス
- CSV (132)
-
CSV
:: Row (3) - Coverage (24)
- Data (3)
- Date (2)
- DateTime (2)
-
Encoding
:: Converter (48) -
Enumerator
:: ArithmeticSequence (7) - Exception (12)
-
Gem
:: Commands :: DependencyCommand (12) -
Gem
:: DependencyInstaller (12) -
Gem
:: DependencyList (12) - Hash (85)
- IO (168)
-
JSON
:: Parser (12) - KeyError (16)
- Module (12)
- Object (36)
- PStore (24)
- Proc (6)
-
Rake
:: TaskArguments (24) - Range (12)
- String (12)
- Struct (4)
- Thread (12)
- Time (2)
モジュール
- Forwardable (24)
- JSON (24)
-
JSON
:: Generator :: GeneratorMethods :: Object (12) -
JSON
:: Generator :: GeneratorMethods :: String :: Extend (12) - Kernel (24)
-
Net
:: HTTPHeader (36) - RbConfig (12)
- TSort (93)
キーワード
- % (12)
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) -
DEFAULT
_ OPTIONS (12) -
MAKEFILE
_ CONFIG (12) - Marshal フォーマット (12)
-
NEWS for Ruby 2
. 1 . 0 (12) -
NEWS for Ruby 2
. 2 . 0 (11) -
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (5) - Numeric (12)
- PStore (12)
- Ruby用語集 (12)
- WIN32OLE (12)
- [] (1)
- cgi (12)
-
cgi
/ session (12) -
deconstruct
_ keys (12) -
default
_ proc= (12) - delegate (12)
- delete (12)
-
each
_ strongly _ connected _ component (23) -
each
_ strongly _ connected _ component _ from (23) - fetch (48)
- filter (36)
-
find
_ gems (12) - format (12)
- generate (24)
-
handle
_ interrupt (12) -
instance
_ delegate (12) - invert (12)
-
is
_ a? (12) -
json
_ create (12) - key (8)
-
kind
_ of? (12) - merge (24)
- new (27)
- open (48)
- parse (24)
-
peek
_ result (12) - popen (168)
- pp (12)
-
primitive
_ convert (48) - rdoc (12)
- receiver (8)
- replace (12)
- result (12)
-
rexml
/ parsers / pullparser (12) - rss (12)
-
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 2 feature (12) -
ruby 1
. 8 . 4 feature (12) -
ruby 1
. 9 feature (12) -
ruby2
_ keywords (18) -
ruby2
_ keywords _ hash? (6) -
spec
_ predecessors (12) - sprintf (12)
- sprintf フォーマット (12)
-
strongly
_ connected _ components (12) -
to
_ h (19) -
to
_ hash (24) -
to
_ json (24) - tsort (24)
-
tsort
_ each (23) - unparse (12)
-
webrick
/ cgi (12) -
with
_ defaults (12) - yaml (12)
- パターンマッチ (12)
- メソッド呼び出し(super・ブロック付き・yield) (12)
- リテラル (12)
検索結果
先頭5件
-
Range
# hash -> Integer (18129.0) -
始端と終端のハッシュ値と Range#exclude_end? の値からハッシュ値を計算して整数として返します。
...始端と終端のハッシュ値と Range#exclude_end? の値からハッシュ値を計算して整数として返します。
//emlist[例][ruby]{
p (1..2).hash # => 5646
p (1...2).hash # => 16782863
//}... -
Enumerator
:: ArithmeticSequence # hash -> Integer (18113.0) -
自身のハッシュ値を返します。
...自身のハッシュ値を返します。
begin, end, step, exclude_end? が等しい Enumerable::ArithmeticSequence は
同じハッシュ値を返します。... -
Hash
. ruby2 _ keywords _ hash?(hash) -> bool (15220.0) -
Module#ruby2_keywordsやProc#ruby2_keywordsによる ruby2_keywords フラグが設定されているかどうかを返します。
...れていません。
ruby 2.7.1 で追加されたため、ruby 2.7.0 では定義されていません。
//emlist[][ruby]{
ruby2_keywords def foo(*args)
Hash.ruby2_keywords_hash?(args.last)
end
foo(k: 1) # => true
foo({k: 1}) # => false
//}
@see Module#ruby2_keywords, Proc#ruby2_keywords... -
Hash
# to _ h -> self | Hash (9212.0) -
self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。
...す。Hash クラスのサブクラスから呼び出した場合は
self を Hash オブジェクトに変換します。
//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true
class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.clas......s # => MyHash
p my_hash.to_h.class # => Hash
//}
ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upcase, value-32] } #... -
Hash
# to _ h {|key , value| block } -> Hash (9212.0) -
self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。
...す。Hash クラスのサブクラスから呼び出した場合は
self を Hash オブジェクトに変換します。
//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true
class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.clas......s # => MyHash
p my_hash.to_h.class # => Hash
//}
ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upcase, value-32] } #... -
Hash
# to _ h -> self | Hash (9199.0) -
self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。
...す。Hash クラスのサブクラスから呼び出した場合は
self を Hash オブジェクトに変換します。
//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true
class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.clas......s # => MyHash
p my_hash.to_h.class # => Hash
//}... -
Hash
# merge(*others) -> Hash (9144.0) -
selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。 デフォルト値はselfの設定のままです。
...値を使います。
othersがハッシュではない場合、othersのメソッドto_hashを使って暗黙の変換を試みます。
@param others マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結......to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France => 'Paris'
}
# 暗黙の変換
p h.merge(Foo.new) # => {:Germany=>"Berlin", :Australia=>"Sydney", :France=>"Paris"}
//}
@see Hash#update,Hash#r... -
Hash
# merge(*others) {|key , self _ val , other _ val| . . . } -> Hash (9144.0) -
selfとothersのハッシュの内容を順番にマージ(統合)した結果を返します。 デフォルト値はselfの設定のままです。
...値を使います。
othersがハッシュではない場合、othersのメソッドto_hashを使って暗黙の変換を試みます。
@param others マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結......to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France => 'Paris'
}
# 暗黙の変換
p h.merge(Foo.new) # => {:Germany=>"Berlin", :Australia=>"Sydney", :France=>"Paris"}
//}
@see Hash#update,Hash#r... -
Hash
# merge(other) -> Hash (9144.0) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...の値を使います。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param other マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結......to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France => 'Paris'
}
# 暗黙の変換
p h.merge(Foo.new) # => {:Germany=>"Berlin", :Australia=>"Sydney", :France=>"Paris"}
//}
@see Hash#update,Hash#r... -
Hash
# merge(other) {|key , self _ val , other _ val| . . . } -> Hash (9144.0) -
selfとotherのハッシュの内容をマージ(統合)した結果を返します。デフォルト値はselfの設定のままです。
...の値を使います。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
@param other マージ用のハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return マージした結......to_hash
{:Australia => 'Sydney',
:France => 'Paris'
}
end
end
h = {:Germany => 'Berlin',
:Australia => 'Canberra',
:France => 'Paris'
}
# 暗黙の変換
p h.merge(Foo.new) # => {:Germany=>"Berlin", :Australia=>"Sydney", :France=>"Paris"}
//}
@see Hash#update,Hash#r... -
Hash
# invert -> Hash (9137.0) -
値からキーへのハッシュを作成して返します。
...備えて、変換後の値を配列として保持するには、次のようにします。
//emlist[][ruby]{
def safe_invert(orig_hash)
orig_hash.each_key.group_by do |key|
orig_hash[key]
end
end
p safe_invert({"a"=>1, "b"=>1, "c"=>3}) # => {1=>["a", "b"], 3=>["c"]}
//}
@see Hash#key... -
Hash
# replace(other) -> self (9060.0) -
ハッシュの内容を other の内容で置き換えます。
...ます。
otherがハッシュではない場合、otherのメソッドto_hashを使って暗黙の変換を試みます。
self = other.to_hash.dup と同じです。
@param other ハッシュまたはメソッド to_hash でハッシュに変換できるオブジェクトです。
@return self......{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
# default _ proc=(pr) (9054.0) -
ハッシュのデフォルト値を返す Proc オブジェクトを 変更します。
...前のデフォルトは値(Hash#default)の場合も
Proc の場合(Hash#default_proc)でも上書きされます。
引数には to_proc で Proc オブジェクトに変換できる
オブジェクトも受け付けます。
nil を指定した場合は現在の Hash#default_proc をクリア......oc = proc do |hash, key|
hash[key] = case
when (key % 15).zero?
"FizzBuzz"
when (key % 5).zero?
"Buzz"
when (key % 3).zero?
"Fizz"
else
key
end
end
p h[1] # =>......2] # => 2
p h[3] # => "Fizz"
p h[5] # => "Buzz"
p h[15] # => "FizzBuzz"
h.default_proc = nil
p h[16] # => nil
# default_proc が nil になったので `16=>16 が追加されていない`
p h # => {1=>1, 2=>2, 3=>"Fizz", 5=>"Buzz", 15=>"FizzBuzz"}
//}
@see Hash#default_proc, Hash#default...