種類
ライブラリ
- ビルトイン (1849)
- abbrev (24)
- bigdecimal (12)
-
cgi
/ core (84) -
cgi
/ session (36) -
cgi
/ session / pstore (12) -
cgi
/ util (12) - coverage (24)
- csv (315)
- date (124)
- dbm (36)
-
digest
/ sha1 (12) -
digest
/ sha2 (36) - drb (12)
- erb (8)
- fileutils (12)
- forwardable (48)
- gdbm (36)
- ipaddr (12)
- irb (12)
- json (180)
-
json
/ add / bigdecimal (12) -
json
/ add / complex (12) -
json
/ add / date (12) -
json
/ add / date _ time (12) -
json
/ add / exception (12) -
json
/ add / ostruct (12) -
json
/ add / range (12) -
json
/ add / rational (12) -
json
/ add / regexp (12) -
json
/ add / struct (12) -
json
/ add / symbol (12) -
json
/ add / time (12) - matrix (24)
-
minitest
/ unit (1) - mkmf (12)
-
net
/ http (48) -
net
/ pop (12) - objspace (36)
- open-uri (12)
- openssl (60)
- optparse (60)
- ostruct (43)
- pathname (12)
- rake (36)
- rbconfig (24)
-
rbconfig
/ sizeof (24) -
rdoc
/ code _ object (12) -
rdoc
/ markup / to _ html _ crossref (12) -
rdoc
/ text (12) -
rinda
/ rinda (48) -
rinda
/ tuplespace (48) - rubygems (36)
-
rubygems
/ command (60) -
rubygems
/ commands / dependency _ command (12) -
rubygems
/ config _ file (24) -
rubygems
/ dependency _ installer (12) -
rubygems
/ dependency _ list (12) -
rubygems
/ remote _ fetcher (12) -
rubygems
/ requirement (12) -
rubygems
/ security (36) -
rubygems
/ source _ index (24) -
rubygems
/ source _ info _ cache (72) -
rubygems
/ spec _ fetcher (24) -
rubygems
/ specification (24) - sdbm (36)
- set (9)
- shell (6)
-
shell
/ command-processor (12) -
shell
/ filter (6) - sync (12)
- uri (72)
-
webrick
/ accesslog (12) -
webrick
/ cgi (12) -
webrick
/ config (36) -
webrick
/ httpauth / htdigest (12) -
webrick
/ httpauth / htpasswd (12) -
webrick
/ httprequest (48) -
webrick
/ httpresponse (24) -
webrick
/ https (12) -
webrick
/ httpservlet / filehandler (12) -
webrick
/ httputils (36) -
webrick
/ server (12) -
webrick
/ ssl (24) -
yaml
/ dbm (12)
クラス
- Array (43)
- BigDecimal (24)
- Bignum (3)
- CGI (48)
-
CGI
:: Cookie (12) -
CGI
:: Session :: FileStore (12) -
CGI
:: Session :: MemoryStore (12) -
CGI
:: Session :: NullStore (12) -
CGI
:: Session :: PStore (12) - CSV (276)
-
CSV
:: Row (15) -
CSV
:: Table (24) - Complex (12)
- Coverage (24)
- DBM (36)
-
DRb
:: DRbServer (12) - Data (12)
- Date (122)
- DateTime (26)
- ERB (8)
- Encoding (12)
-
Enumerator
:: ArithmeticSequence (7) - Exception (12)
- Float (12)
- GDBM (36)
-
Gem
:: Command (60) -
Gem
:: Commands :: DependencyCommand (12) -
Gem
:: ConfigFile (24) -
Gem
:: DependencyInstaller (12) -
Gem
:: DependencyList (12) -
Gem
:: RemoteFetcher (12) -
Gem
:: Requirement (12) -
Gem
:: SourceIndex (24) -
Gem
:: SourceInfoCache (72) -
Gem
:: SpecFetcher (24) -
Gem
:: Specification (24) - Hash (1182)
- IPAddr (12)
-
JSON
:: State (24) - MatchData (26)
- Matrix (12)
- Method (12)
-
MiniTest
:: Unit (1) -
Net
:: HTTPResponse (24) -
Net
:: POP3 (12) - Object (36)
-
OpenSSL
:: Config (12) -
OpenSSL
:: SSL :: SSLContext (12) -
OpenSSL
:: X509 :: Extension (12) -
OpenSSL
:: X509 :: ExtensionFactory (12) -
OpenSSL
:: X509 :: Name (12) - OpenStruct (55)
- OptionParser (48)
- Pathname (12)
- Proc (12)
-
RDoc
:: CodeObject (12) -
RDoc
:: Markup :: ToHtmlCrossref (12) -
RDoc
:: Options (12) -
Rake
:: TaskArguments (36) - Range (24)
- Rational (24)
- Regexp (24)
-
Rinda
:: TupleEntry (12) -
Rinda
:: TupleSpace (36) -
Rinda
:: TupleSpaceProxy (36) -
RubyVM
:: InstructionSequence (12) - SDBM (36)
- Set (12)
- Shell (6)
-
Shell
:: CommandProcessor (12) -
Shell
:: Filter (6) - String (60)
- Struct (49)
- Symbol (12)
- Thread (12)
- Time (26)
-
URI
:: FTP (12) -
URI
:: Generic (24) -
URI
:: HTTP (12) -
URI
:: LDAP (12) -
URI
:: MailTo (12) - UnboundMethod (12)
- Vector (12)
-
WEBrick
:: CGI (12) -
WEBrick
:: GenericServer (12) -
WEBrick
:: HTTPAuth :: Htdigest (12) -
WEBrick
:: HTTPAuth :: Htpasswd (12) -
WEBrick
:: HTTPRequest (48) -
WEBrick
:: HTTPResponse (24) -
WEBrick
:: HTTPServlet :: FileHandler (12) -
YAML
:: DBM (12)
モジュール
- Abbrev (12)
-
CGI
:: QueryExtension (48) - Enumerable (41)
- FileUtils (12)
- Forwardable (24)
- GC (36)
-
GC
:: Profiler (12) - Gem (12)
-
Gem
:: QuickLoader (24) -
Gem
:: Security (36) - IRB (12)
-
JSON
:: Generator :: GeneratorMethods :: Array (12) -
JSON
:: Generator :: GeneratorMethods :: FalseClass (12) -
JSON
:: Generator :: GeneratorMethods :: Float (12) -
JSON
:: Generator :: GeneratorMethods :: Hash (12) -
JSON
:: Generator :: GeneratorMethods :: Integer (12) -
JSON
:: Generator :: GeneratorMethods :: NilClass (12) -
JSON
:: Generator :: GeneratorMethods :: Object (12) -
JSON
:: Generator :: GeneratorMethods :: String (24) -
JSON
:: Generator :: GeneratorMethods :: String :: Extend (12) -
JSON
:: Generator :: GeneratorMethods :: TrueClass (12) - Kernel (72)
- Marshal (24)
-
Net
:: HTTPHeader (24) - ObjectSpace (48)
-
OpenURI
:: Meta (12) -
OptionParser
:: Arguable (12) -
RDoc
:: Text (12) - RbConfig (48)
- Signal (12)
- SingleForwardable (24)
-
Sync
_ m (12) -
WEBrick
:: AccessLog (12) -
WEBrick
:: Config (72) -
WEBrick
:: HTTPUtils (36)
オブジェクト
- ENV (109)
キーワード
- < (10)
- <= (10)
- == (12)
- === (12)
- > (10)
- >= (10)
- BasicAuth (12)
-
CODE
_ CLASS _ TO _ OBJ (12) -
CODE
_ TO _ OBJ (12) - CONFIG (24)
- ConfigMap (12)
- Converters (12)
-
DEFAULT
_ OPTIONS (24) - DefaultMimeTypes (12)
- DigestAuth (12)
- FileHandler (12)
- GemPaths (12)
- GemVersions (12)
- General (12)
- HTTP (12)
-
HTTP
_ STATUS (12) - HandlerTable (12)
- HeaderConverters (12)
- InvalidHashTupleKey (12)
- LIMITS (12)
-
MAKEFILE
_ CONFIG (12) -
MARSHAL
_ FIELDS (12) - Marshal フォーマット (12)
- OPS (12)
- OPT (12)
-
OPT
_ TABLE (12) -
PATH
_ SEPARATOR (12) - Policies (12)
- RHASH (12)
-
SCRIPT
_ LINES _ _ (12) - SHA1 (12)
- SHA256 (12)
- SHA384 (12)
- SHA512 (12)
- SIZEOF (12)
-
SPECIFICATION
_ VERSION _ HISTORY (12) - SSL (12)
-
TABLE
_ FOR _ ESCAPE _ HTML _ _ (12) - [] (36)
- []= (24)
-
_ httpdate (12) -
_ iso8601 (12) -
_ jisx0301 (12) -
_ parse (12) -
_ rfc2822 (12) -
_ rfc3339 (12) -
_ rfc822 (12) -
_ strptime (24) -
_ xmlschema (12) - abbrev (24)
-
add
_ specs (12) -
alias
_ map (6) - aliases (12)
- assoc (12)
- attributes (12)
- build (60)
- build2 (12)
-
build
_ self _ signed _ cert (12) -
cache
_ data (24) - classify (12)
- clear (12)
- clone (12)
- compact (15)
- compact! (9)
-
compare
_ by _ identity (12) -
compare
_ by _ identity? (12) -
compile
_ option (12) - conf (12)
- config (48)
-
count
_ nodes (12) -
count
_ objects (12) -
count
_ objects _ size (12) -
count
_ tdata _ objects (12) -
create
_ ext _ from _ hash (12) -
deconstruct
_ keys (20) - default (24)
- default= (12)
-
default
_ proc (12) -
default
_ proc= (12) - defaults (12)
- defaults= (12)
- delegate (24)
- delete (24)
-
delete
_ if (24) - dig (10)
-
digest
/ sha1 (12) -
digest
/ sha2 (12) - dump (24)
- dup (12)
- each (84)
-
each
_ key (24) -
each
_ pair (24) -
each
_ value (24) - empty? (12)
- eql? (12)
- equal? (12)
- except (8)
- fetch (48)
-
fetch
_ path (12) -
fetch
_ values (20) - files (12)
- filter (57)
- filter! (14)
-
find
_ gems (12) - flatten (12)
- foreach (24)
- generate (12)
-
generate
_ line (12) - getopts (60)
-
group
_ by (12) - gsub (12)
- gsub! (12)
-
handle
_ interrupt (12) -
has
_ key? (12) -
has
_ value? (12) - hash (265)
-
hash
_ old (12) - header (24)
- include? (12)
- index (7)
- inspect (12)
- instance (24)
-
instance
_ delegate (12) - invert (60)
-
json
_ create (156) -
keep
_ if (24) - key (12)
- key? (12)
- keys (12)
-
latest
_ cache _ data (12) -
latest
_ gc _ info (12) -
latest
_ specs (12) - length (12)
- list (12)
-
load
_ mime _ types (12) -
mark
_ hashentry (12) - member? (12)
- merge (24)
- merge! (24)
- modifiable (12)
-
named
_ captures (12) - new (60)
- numhash (12)
- open (48)
- params (12)
- params= (12)
- parse (48)
-
parse
_ header (12) -
parse
_ line (12) -
peek
_ result (12) -
process
_ args (1) - query (12)
- rassoc (12)
-
raw
_ data (12) -
rb
_ f _ hash (12) -
rb
_ mark _ hash (12) - read (36)
-
read
_ all (24) -
read
_ cache _ data (12) - readlines (12)
- rehash (54)
- reject (72)
- reject! (24)
- replace (24)
-
reset
_ cache _ for (12) - restore (48)
- result (12)
-
result
_ with _ hash (8) -
ruby 1
. 9 feature (12) -
ruby2
_ keywords _ hash? (6) - select (36)
- select! (24)
-
set
_ cache _ data (12) -
set
_ params (12) -
setup
_ params (12) - shift (12)
-
show
_ hash (12) -
single
_ delegate (12) - size (12)
- slice (15)
- spawn (48)
-
spec
_ predecessors (12) -
specific
_ extra _ args _ hash (12) - specs (12)
-
ssl
_ params (12) -
st
_ init _ table (12) -
st
_ init _ table _ with _ size (12) - stat (12)
- store (12)
- strhash (12)
-
strip
_ hashes (12) - sub (12)
- sub! (12)
-
sync
_ sh _ locker (6) -
sync
_ sh _ locker= (6) - table (12)
- take (24)
- tally (10)
-
to
_ a (12) -
to
_ csv (12) -
to
_ h (132) -
to
_ hash (120) -
to
_ json (108) -
to
_ json _ raw _ object (12) -
to
_ proc (10) -
to
_ s (24) -
transform
_ keys (20) -
transform
_ keys! (20) -
transform
_ values (18) -
transform
_ values! (18) -
try
_ convert (12) -
type
_ params (12) - update (24)
- value (12)
- value? (12)
- values (12)
-
values
_ at (12) -
verify
_ compaction _ references (6) -
with
_ defaults (12)
検索結果
先頭5件
-
Hash (44030.0)
-
ハッシュテーブル(連想配列とも呼ぶ)のクラスです。ハッシュは任意の種類のオブ ジェクト(キー)から任意の種類のオブジェクト(値)への関連づけを行うことができます。
...クト(値)への関連づけを行うことができます。
ハッシュ生成は多くの場合以下のようなリテラル (d:spec/literal#hash) で行われます。
{a => b, ... } # aはキー、bは値となる
{s: b , ... } # { :s => b, ... } と同じ。キーがシンボル......ある必要があります。
* Object#hash ハッシュの格納に用いられるハッシュ値の計算
* Object#eql? キーの同一性判定
破壊的操作によってキーとして与えたオブジェクトの内容が変化し、Object#hash の返す
値が変わるとハッシュ......から値が取り出せなくなりますから、
Array、Hash
などのインスタンスはキーに向きません。Hash#rehash を参照。
ただし、 更新不可 (Object#frozen? が true) では無い文字列をキーとして与えた場合は、文字列をコピーし、コピーを... -
Hash
. ruby2 _ keywords _ hash?(hash) -> bool (36414.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 _ hash -> self (36249.0) -
self を返します。
...self を返します。
//emlist[例][ruby]{
hash = {}
p hash.to_hash # => {}
p hash.to_hash == hash # => true
//}
@see Object#to_hash, Hash#to_h... -
Hash
# hash -> Integer (36213.0) -
自身が保持するキーと値のハッシュ値を元にして算出した整数を返します。 自身が保持するキーや値が変化すればこのメソッドが返す値も変化します。
...自身が保持するキーと値のハッシュ値を元にして算出した整数を返します。
自身が保持するキーや値が変化すればこのメソッドが返す値も変化します。
//emlist[例][ruby]{
a = {}
p a.hash #=> 0
a[1] = :x
p a.hash #=> 329543
//}... -
Hash
# rehash -> self (36212.0) -
キーのハッシュ値を再計算します。
...raise RuntimeError Hash#eachなどのイテレータの評価途中でrehashすると発生します。
@return selfを返します。
//emlist[例][ruby]{
a = [ "a", "b" ]
h = { a => 100 }
p h[a] #=> 100
a[0] = "z"
p h[a] #=> nil
h.rehash
p h[a] #=> 100
//}
@see Object#hash... -
Hash
# shift -> [object , object] | nil (30124.0) -
ハッシュからキーが追加された順で先頭の要素をひとつ取り除き、 [key, value]という配列として返します。
...ue]という配列として返します。
shiftは破壊的メソッドです。selfは要素を取り除かれた残りのハッシュに変更されます。
Ruby 3.2以前は、ハッシュが空の場合、デフォルト値(Hash#defaultまたはHash#default_procのブロックの値か、......, :cd => "all"}
p h.shift #=> [:ab, "some"]
p h.shift #=> [:cd, "all"]
p h #=> {}
p h.shift #=> nil
h1 = Hash.new("default value")
p h1 #=> {}
p h1.shift #=> "default value"
h2 = Hash.new {|*arg| arg}
p......h2 #=> {}
p h2.shift #=> [{}, nil]
//}
@see Array#shift......します。
shiftは破壊的メソッドです。selfは要素を取り除かれた残りのハッシュに変更されます。
ハッシュが空の場合、デフォルト値に関わらず nil を返します。
//emlist[例][ruby]{
h = {:ab => "some" , :cd => "all"}
p h.shift......> [:ab, "some"]
p h.shift #=> [:cd, "all"]
p h #=> {}
p h.shift #=> nil
h1 = Hash.new("default value")
p h1 #=> {}
p h1.shift #=> nil
h2 = Hash.new {|*arg| arg}
p h2 #=> {}
p h2.shift #=......> nil
//}
@see Array#shift... -
Hash
. new {|hash , key| . . . } -> Hash (24490.0) -
空の新しいハッシュを生成します。ブロックの評価結果がデフォルト値になりま す。設定したデフォルト値はHash#default_procで参照できます。
...空の新しいハッシュを生成します。ブロックの評価結果がデフォルト値になりま
す。設定したデフォルト値はHash#default_procで参照できます。
値が設定されていないハッシュ要素を参照するとその都度ブロックを
実行し、そ......ォルト値は全部同一のオブジェクトなので、
# 破壊的変更によって他のキーに対応する値も変更されます。
h = Hash.new("foo")
p h[1] #=> "foo"
p h[1].object_id #=> 6127170
p h[1] << "bar" #=> "foobar"
p h[1] #=>......まだ無いキーが呼び出される度に
# ブロックを評価するので、全て別のオブジェクトになります。
h = Hash.new {|hash, key| hash[key] = "foo"}
p h[1] #=> "foo"
p h[1].object_id #=> 6126900
p h[1] << "bar" #=> "foobar"
p h[1]... -
Kernel
. # Hash(arg) -> Hash (24474.0) -
引数 arg で指定したオブジェクトを to_hash メソッドを呼び出す事で Hash オブジェクトに変換します。nil か [] を指定した場合は空の Hash オブジェクトを返します。
...を to_hash メソッドを呼び出す事で
Hash オブジェクトに変換します。nil か [] を指定した場合は空の
Hash オブジェクトを返します。
@param arg 変換対象のオブジェクトを指定します。
//emlist[例][ruby]{
Hash([]) # => {}
Hash(nil)......# => {}
Hash(key: :value) # => {:key => :value}
Hash([1, 2, 3]) # => TypeError
//}
@raise TypeError 変換できないオブジェクトを指定した場合に発生します。... -
Hash
# transform _ keys(hash) -> Hash (24427.0) -
すべてのキーに対してブロックを呼び出した結果で置き換えたハッシュを返します。 値は変化しません。
...べてのキーに対してブロックを呼び出した結果で置き換えたハッシュを返します。
値は変化しません。
@param hash 置き換え前のキーから置き換え後のキーへのハッシュを指定します。
//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.tran......") # => {"a"=>1, :b=>2, :c=>3}
h.transform_keys(&:to_s) # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys.with_index {|k, i| "#{k}.#{i}" }
# => {"a.0"=>1, "b.1"=>2, "c.2"=>3}
//}
@see Hash#transform_keys!
@see Hash#transform_values
@see Hash#transform_values!... -
Hash
# to _ h -> self | Hash (24306.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] } #...