別のキーワード
ライブラリ
- ビルトイン (84)
- digest (84)
-
net
/ http (12) - optparse (144)
-
rake
/ packagetask (12) -
rubygems
/ commands / update _ command (12)
クラス
-
Digest
:: Base (84) -
Gem
:: Commands :: UpdateCommand (12) - Hash (72)
- OptionParser (144)
-
Rake
:: PackageTask (12)
モジュール
- Enumerable (12)
-
Net
:: HTTPHeader (12)
キーワード
- == (24)
- []= (12)
- chunk (12)
- digest (12)
- digest! (12)
-
do
_ rubygems _ update (12) - hexdigest (12)
- hexdigest! (12)
- merge (24)
- merge! (24)
- name= (12)
-
on
_ head (12) -
on
_ tail (12) - parse (24)
- parse! (12)
- summarize (24)
-
summary
_ indent (12) -
summary
_ indent= (12) -
summary
_ width (12) -
summary
_ width= (12) -
to
_ a (12) -
to
_ s (12)
検索結果
先頭5件
-
Gem
:: Commands :: UpdateCommand # do _ rubygems _ update(version) (15202.0) -
RubyGems 自体を更新します。
...
RubyGems 自体を更新します。... -
Hash
# update(*others) -> self (15145.0) -
selfとothersのハッシュの内容を順番にマージ(統合)します。
...ェクトです。
@return マージ後のselfを返します。
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h1.merge! #=> {"a"=>100, "b"=>200}
h1 #=> {"a"=>100, "b"=>200}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h1.merge!......c"=>300}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b......=>100, "b"=>200, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => 'D'}
p foo.update(bar) #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo.update(bar) {|key, foo_val, bar_val| foo_val + bar_val } #... -
Hash
# update(*others) {|key , self _ val , other _ val| . . . } -> self (15145.0) -
selfとothersのハッシュの内容を順番にマージ(統合)します。
...ェクトです。
@return マージ後のselfを返します。
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h1.merge! #=> {"a"=>100, "b"=>200}
h1 #=> {"a"=>100, "b"=>200}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h1.merge!......c"=>300}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b......=>100, "b"=>200, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => 'D'}
p foo.update(bar) #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo.update(bar) {|key, foo_val, bar_val| foo_val + bar_val } #... -
Hash
# update(other) -> self (15127.0) -
selfとotherのハッシュの内容をマージ(統合)します。
...mlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge!(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1 # => {"a"=>100, "b"=>254, "c"=>300}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => 'D'}
p foo.update(bar) #......=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo.update(bar) {|key, foo_val, bar_val| foo_val + bar_val } # => {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
p foo # => {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
//}
@see Hash#merge!... -
Hash
# update(other) {|key , self _ val , other _ val| . . . } -> self (15127.0) -
selfとotherのハッシュの内容をマージ(統合)します。
...mlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge!(h2) # => {"a"=>100, "b"=>254, "c"=>300}
h1 # => {"a"=>100, "b"=>254, "c"=>300}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => 'D'}
p foo.update(bar) #......=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo.update(bar) {|key, foo_val, bar_val| foo_val + bar_val } # => {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
p foo # => {1=>"a", 2=>"BB", 3=>"CC", 4=>"DD"}
//}
@see Hash#merge!... -
Enumerable
# chunk {|elt| . . . } -> Enumerator (49.0) -
要素を前から順にブロックで評価し、その結果によって 要素をチャンクに分けた(グループ化した)要素を持つ Enumerator を返します。
...//emlist[][ruby]{
enum.chunk {|elt| key }.each {|key, ary| do_something }
//}
例として、整数列を連続する奇数/偶数に分ける例を見てみます。
「n.even?」の値が切り替わるところで区切られているのがわかるでしょう。
//emlist[例][ruby]{
[3, 1, 4......ストを改行で区切って収めたものです。
大文字/小文字の違いを無視するため upcase しています。
//emlist[例][ruby]{
# ファイルのエンコーディングは実際のファイルに合わせてください。
open("/usr/share/dict/words", "r:iso-8859-1") {|f......釈されます。
それ以外のアンダースコアで始まるシンボルを指定した場合は例外が発生します。
//emlist[例][ruby]{
[1, 2].chunk { |item| :_underscore }.to_a
# => RuntimeError: symbols beginning with an underscore are reserved
# 「.to_a」無しだと Enumerat... -
Hash
# merge!(*others) -> self (45.0) -
selfとothersのハッシュの内容を順番にマージ(統合)します。
...ェクトです。
@return マージ後のselfを返します。
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h1.merge! #=> {"a"=>100, "b"=>200}
h1 #=> {"a"=>100, "b"=>200}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h1.merge!......c"=>300}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b......=>100, "b"=>200, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => 'D'}
p foo.update(bar) #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo.update(bar) {|key, foo_val, bar_val| foo_val + bar_val } #... -
Hash
# merge!(*others) {|key , self _ val , other _ val| . . . } -> self (45.0) -
selfとothersのハッシュの内容を順番にマージ(統合)します。
...ェクトです。
@return マージ後のselfを返します。
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h1.merge! #=> {"a"=>100, "b"=>200}
h1 #=> {"a"=>100, "b"=>200}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h1.merge!......c"=>300}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 246, "c" => 300 }
h3 = { "b" => 357, "d" => 400 }
h1.merge!(h2, h3) #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
h1 #=> {"a"=>100, "b"=>357, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
h1 = { "a" => 100, "b......=>100, "b"=>200, "c"=>300, "d"=>400}
//}
//emlist[][ruby]{
foo = {1 => 'a', 2 => 'b', 3 => 'c'}
bar = {2 => 'B', 3 => 'C', 4 => 'D'}
p foo.update(bar) #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo #=> {1=>"a", 2=>"B", 3=>"C", 4=>"D"}
p foo.update(bar) {|key, foo_val, bar_val| foo_val + bar_val } #... -
Digest
:: Base # ==(md) -> bool (39.0) -
与えられたダイジェストオブジェクトと比較します。
...ェストオブジェクト
require 'digest/md5'
digest1 = Digest::MD5.new
digest1.update("ruby")
digest2 = Digest::MD5.new
digest2.update("ruby")
p digest1 == digest2 # => true
digest2.update("RUBY")
p digest1 == digest2 # => false... -
Digest
:: Base # hexdigest -> String (35.0) -
updateや<<によって追加した文字列に対するハッシュ値を、 ASCIIコードを使って16進数の列を示す文字列にエンコードして返します。
...
updateや<<によって追加した文字列に対するハッシュ値を、
ASCIIコードを使って16進数の列を示す文字列にエンコードして返します。
返す文字列は、
MD5では32バイト長、SHA1およびRMD160では40バイト長、SHA256では64バイト長、
SH......は96バイト長、SHA512では128バイト長です。
Rubyで書くと以下と同じです。
def hexdigest
digest.unpack("H*")[0]
end
例:
# MD5の場合
require 'digest/md5'
digest = Digest::MD5.new
digest.update("ruby")
p digest.hexdigest # => "58e53d1324eef6265fdb97b08e... -
Digest
:: Base # to _ s -> String (35.0) -
updateや<<によって追加した文字列に対するハッシュ値を、 ASCIIコードを使って16進数の列を示す文字列にエンコードして返します。
...
updateや<<によって追加した文字列に対するハッシュ値を、
ASCIIコードを使って16進数の列を示す文字列にエンコードして返します。
返す文字列は、
MD5では32バイト長、SHA1およびRMD160では40バイト長、SHA256では64バイト長、
SH......は96バイト長、SHA512では128バイト長です。
Rubyで書くと以下と同じです。
def hexdigest
digest.unpack("H*")[0]
end
例:
# MD5の場合
require 'digest/md5'
digest = Digest::MD5.new
digest.update("ruby")
p digest.hexdigest # => "58e53d1324eef6265fdb97b08e... -
Digest
:: Base # digest -> String (29.0) -
updateや<<によって追加した文字列に対するハッシュ値を文字列で返します。
...
updateや<<によって追加した文字列に対するハッシュ値を文字列で返します。
返す文字列は、MD5では16バイト長、SHA1およびRMD160では20バイト長、
SHA256では32バイト長、SHA384では48バイト長、SHA512では64バイト長です。
例:
# M......D5の場合
require 'digest/md5'
digest = Digest::MD5.new
digest.update("ruby")
p digest.digest # => "X\345=\023$\356\366&_\333\227\260\216\331\252\337"
@see Digest::Base#hexdigest...