77件ヒット
[1-77件を表示]
(0.031秒)
種類
- インスタンスメソッド (30)
- 文書 (25)
- 特異メソッド (11)
- モジュール関数 (11)
ライブラリ
- ビルトイン (41)
- securerandom (11)
モジュール
- Kernel (11)
- SecureRandom (11)
キーワード
- Integer (11)
-
NEWS for Ruby 3
. 1 . 0 (3) - pack (19)
- pack テンプレート文字列 (11)
-
ruby 1
. 6 feature (11) - unpack (11)
検索結果
先頭5件
-
SecureRandom
. hex(n = nil) -> String (18230.0) -
ランダムな hex 文字列を生成して返します。
...ランダムな hex 文字列を生成して返します。
@param n 文字列の生成に使われるランダムネスのサイズを整数で指定します。
生成される文字列のサイズではないことに注意して下さい。生成される文字列のサイズは......n の 2 倍になります。nil を指定した場合 n として 16 が使われます。
@raise NotImplementedError 安全な乱数発生器が使えない場合に発生します。
require 'securerandom'
p SecureRandom.hex(3) #=> "f72233" (文字列のサイズは 3 でない)... -
ruby 1
. 6 feature (270.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
... nil
を返すようになりました。(String#[]やString#slice と同じ結果を返すと
いうことです)
p "foo".slice!("bar") # <- 以前からこちらは nil を返していた
p "foo".slice!(5,10)
=> ruby 1.6.7 (2002-03-01) [i586-linux]
nil......: index 5 out of string (IndexError)
from -:2
=> ruby 1.6.7 (2002-08-01) [i586-linux]
nil
nil
: 2002-07-05 String#split
最初の引数に nil を指定できるようになりました。((<ruby-talk:43513>))
この場合、$; を分割文字列......、機能追加 ((<ruby-dev:16139>)),((<ruby-dev:16153>))。
: 数値リテラルの `_'
`_' を置ける場所の規則が見直され、String#hex などの数値変換メソッド
の挙動と共に規則が統一されました。((<rubyist:1018>)), ((<ruby-dev:15684>)),
((<ruby-dev:1575... -
Kernel
. # Integer(arg , base = 0 , exception: true) -> Integer | nil (131.0) -
引数を整数(Fixnum,Bignum)に変換した結果を返します。
...数) です。
@param exception false を指定すると、変換できなかった場合、
例外を発生する代わりに nil を返します。
@raise ArgumentError 整数と見なせない文字列を引数に指定した場合に発生します。
@raise TypeError メ......合に発生します。
@raise TypeError 引数に nil を指定した場合に発生します。
//emlist[例][ruby]{
p Integer(4) #=> 4
p Integer(4_000) #=> 4000
p Integer(9.88) #=> 9
p Integer(nil) # can't convert nil into Integer (TypeError)
p Integer(Object.new) #......teger("1\n0") # `Integer': invalid value for Integer: "1\n0" (ArgumentError)
p Integer("hoge") # `Integer': invalid value for Integer: "hoge" (ArgumentError)
p Integer("") # `Integer': invalid value for Integer: "" (ArgumentError)
//}
@see String#hex,String#oct,String#to_i,Integer... -
NEWS for Ruby 3
. 1 . 0 (54.0) -
NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
....com/ruby/ruby/pull/1509
//emlist[Enumerable#each_cons Enumerable#each_slice][ruby]{
[1, 2, 3].each_cons(2){}
# 3.0 => nil
# 3.1 => [1, 2, 3]
[1, 2, 3].each_slice(2){}
# 3.0 => nil
# 3.1 => [1, 2, 3]
//}
* Enumerator::Lazy
* 新規メソッド
* Enumerator::Lazy#compact が追加さ......unctionが引数を返すようになりました。引数が1つでも渡されている場合、それが返されます。引数なしの場合、nilが返されます。複数の引数を渡した場合、それらを要素に持つ配列が返されます。 12495
* Process
* 新規メ......。詳細は 18176 を参照してください。
* Random::Formatterは random/formatter.rb に移動され、SecureRandomを使わずに Random#hex や Random#base64 などが使用できるようになりました。 18190
== 互換性 (機能追加とバグ修正を除く)
* rb_io_wait_rea... -
Array
# pack(template) -> String (42.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
..."\x98\xE5\x9ER\xD2U\x00\x00p\xE5\x9ER\xD2U\x00\x00H\xE5\x9ER\xD2U\x00\x00"
[nil].pack("p") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
//}
: P
構造体(固定長文字列)へのポインタ
//emlist[][ruby]{
[nil].pack("P") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
["abc"].pack("P3") #......ck('ccxxcc') # => [82, 117, 98, 121]
//}
: Hexダンプを数値の配列に変換する例
//emlist[][ruby]{
"61 62 63 64 65 66".delete(' ').lines.pack('H*').unpack('C*')
# => [97, 98, 99, 100, 101, 102]
"61 62 63 64 65 66".split.collect {|c| c.hex}
# => [97, 98, 99, 100, 101, 102]
//}
: バ......}
"p" や "P" は、nil を特別に扱い NULL
ポインタとして解釈します。(以下は、64bitマシンで一般的な結果)
//emlist[][ruby]{
[nil].pack("p") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00".unpack("p") # => [nil]
//}
: 構造体の... -
Array
# pack(template , buffer: String . new) -> String (42.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
..."\x98\xE5\x9ER\xD2U\x00\x00p\xE5\x9ER\xD2U\x00\x00H\xE5\x9ER\xD2U\x00\x00"
[nil].pack("p") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
//}
: P
構造体(固定長文字列)へのポインタ
//emlist[][ruby]{
[nil].pack("P") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
["abc"].pack("P3") #......ck('ccxxcc') # => [82, 117, 98, 121]
//}
: Hexダンプを数値の配列に変換する例
//emlist[][ruby]{
"61 62 63 64 65 66".delete(' ').lines.pack('H*').unpack('C*')
# => [97, 98, 99, 100, 101, 102]
"61 62 63 64 65 66".split.collect {|c| c.hex}
# => [97, 98, 99, 100, 101, 102]
//}
: バ......}
"p" や "P" は、nil を特別に扱い NULL
ポインタとして解釈します。(以下は、64bitマシンで一般的な結果)
//emlist[][ruby]{
[nil].pack("p") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00".unpack("p") # => [nil]
//}
: 構造体の... -
String
# unpack(template) -> Array (42.0) -
Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。
..."\x98\xE5\x9ER\xD2U\x00\x00p\xE5\x9ER\xD2U\x00\x00H\xE5\x9ER\xD2U\x00\x00"
[nil].pack("p") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
//}
: P
構造体(固定長文字列)へのポインタ
//emlist[][ruby]{
[nil].pack("P") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
["abc"].pack("P3") #......ck('ccxxcc') # => [82, 117, 98, 121]
//}
: Hexダンプを数値の配列に変換する例
//emlist[][ruby]{
"61 62 63 64 65 66".delete(' ').lines.pack('H*').unpack('C*')
# => [97, 98, 99, 100, 101, 102]
"61 62 63 64 65 66".split.collect {|c| c.hex}
# => [97, 98, 99, 100, 101, 102]
//}
: バ......}
"p" や "P" は、nil を特別に扱い NULL
ポインタとして解釈します。(以下は、64bitマシンで一般的な結果)
//emlist[][ruby]{
[nil].pack("p") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00".unpack("p") # => [nil]
//}
: 構造体の... -
pack テンプレート文字列 (42.0)
-
pack テンプレート文字列
..."\x98\xE5\x9ER\xD2U\x00\x00p\xE5\x9ER\xD2U\x00\x00H\xE5\x9ER\xD2U\x00\x00"
[nil].pack("p") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
//}
: P
構造体(固定長文字列)へのポインタ
//emlist[][ruby]{
[nil].pack("P") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
["abc"].pack("P3") #......ck('ccxxcc') # => [82, 117, 98, 121]
//}
: Hexダンプを数値の配列に変換する例
//emlist[][ruby]{
"61 62 63 64 65 66".delete(' ').lines.pack('H*').unpack('C*')
# => [97, 98, 99, 100, 101, 102]
"61 62 63 64 65 66".split.collect {|c| c.hex}
# => [97, 98, 99, 100, 101, 102]
//}
: バ......}
"p" や "P" は、nil を特別に扱い NULL
ポインタとして解釈します。(以下は、64bitマシンで一般的な結果)
//emlist[][ruby]{
[nil].pack("p") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00".unpack("p") # => [nil]
//}
: 構造体の... -
Kernel
. # Integer(arg , base = 0) -> Integer (24.0) -
引数を整数(Fixnum,Bignum)に変換した結果を返します。
...合に発生します。
@raise TypeError 引数に nil を指定した場合に発生します。
//emlist[例][ruby]{
p Integer(4) #=> 4
p Integer(4_000) #=> 4000
p Integer(9.88) #=> 9
p Integer(nil) # can't convert nil into Integer (TypeError)
p Integer(Object.new) #......teger("1\n0") # `Integer': invalid value for Integer: "1\n0" (ArgumentError)
p Integer("hoge") # `Integer': invalid value for Integer: "hoge" (ArgumentError)
p Integer("") # `Integer': invalid value for Integer: "" (ArgumentError)
//}
@see String#hex,String#oct,String#to_i,Integer...