クラス
-
ARGF
. class (18) - Array (19)
- Enumerator (44)
- IO (18)
- Object (44)
- String (33)
- StringIO (18)
-
Zlib
:: GzipReader (11)
モジュール
- Enumerable (22)
-
OpenSSL
:: Buffering (11)
検索結果
先頭5件
-
OpenSSL
:: Buffering # each _ byte {|ch| . . . } -> () (21108.0) -
現在の読み込み位置から 1 バイトずつ読み込み、 それを文字列としてブロックの引数として呼び出します。
...現在の読み込み位置から 1 バイトずつ読み込み、
それを文字列としてブロックの引数として呼び出します。
IO#each_byte と同様です。... -
Zlib
:: GzipReader # each _ byte -> Enumerator (18231.0) -
IO クラスの同名メソッドIO#each_byteと同じです。
...IO クラスの同名メソッドIO#each_byteと同じです。
但し、gzip ファイル中に
エラーがあった場合 Zlib::Error 例外や
Zlib::GzipFile::Error 例外が発生します。
gzip ファイルのフッターの処理に注意して下さい。
gzip ファイルのフッター......EOF まで読み込んだ後、Zlib::GzipFile#close メソッドが
呼び出された時。
* EOF まで読み込んだ後、Zlib::GzipReader#unused メソッドが
呼び出された時。
@raise Zlib::Error Zlib::Error を参照
@raise Zlib::GzipFile::Error Zlib::GzipFile::Errorを参......r Zlib::GzipFile::LengthErrorを参照
require 'zlib'
=begin
# hoge.gz がない場合は下記で作成できる。
Zlib::GzipWriter.open('hoge.gz') { |gz|
gz.puts 'hoge'
}
=end
Zlib::GzipReader.open('hoge.gz') { |gz|
gz.each_byte { |b|
printf "%d -> %c\n", b, b
}... -
ARGF
. class # each _ byte -> Enumerator (18215.0) -
ARGF の現在位置から 1 バイトずつ読み込み、それを整数として与え、ブロックを実行します。 ブロック引数byteは0..255のいずれかの整数です。
...現在位置の1バイトについてファイル名を得るには
ARGF.class#filename を使用します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを生成して返します。
例:
ARGF.each_byte.to_a # => [35, 32, ... 95, 10]
@see IO#each_byte... -
String
# each _ byte -> Enumerator (18215.0) -
文字列の各バイトに対して繰り返します。
...文字列の各バイトに対して繰り返します。
//emlist[例][ruby]{
"str".each_byte do |byte|
p byte
end
# => 115
# => 116
# => 114
"あ".each_byte do |byte|
p byte
end
# => 227
# => 129
# => 130
//}
@see String#bytes... -
StringIO
# each _ byte -> Enumerator (18215.0) -
自身から 1 バイトずつ読み込み、整数 ch に変換し、それを引数として与えられたブロックを実行します。
...変換し、それを引数として与えられたブロックを実行します。
@raise IOError 自身が読み取り不可なら発生します。
//emlist[例][ruby]{
require "stringio"
a = StringIO.new("hoge")
a.each_byte{|ch| p ch }
#=> 104
# 111
# 103
# 101
//}
@see IO#each_byte... -
IO
# each _ byte -> Enumerator (18209.0) -
IO の現在位置から 1 バイトずつ読み込み、それを整数として与え、ブロックを実行します。
...合は、自身から生成した
Enumerator オブジェクトを返します。
バイナリ読み込みメソッドとして動作します。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "aあ")
File... -
StringIO
# each _ byte -> Enumerator (15215.0) -
自身から 1 バイトずつ読み込み、整数 ch に変換し、それを引数として与えられたブロックを実行します。
...変換し、それを引数として与えられたブロックを実行します。
@raise IOError 自身が読み取り不可なら発生します。
//emlist[例][ruby]{
require "stringio"
a = StringIO.new("hoge")
a.each_byte{|ch| p ch }
#=> 104
# 111
# 103
# 101
//}
@see IO#each_byte... -
String
# unpack(template) -> Array (6305.0) -
Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。
...の要素を含む配列を返します。
@param template pack テンプレート文字列
@return オブジェクトの配列
以下にあげるものは、Array#pack、String#unpack
のテンプレート文字の一覧です。テンプレート文字は後に「長さ」を表......big endian unsigned 16bit
N: big endian unsigned 32bit
v: little endian unsigned 16bit
V: little endian unsigned 32bit
//}
: エンディアン依存、整数サイズ依存 (C の構造体などに適切)
//emlist{
s!: signed short
S!: unsigned short
i,i!: signed int
I,I!: unsigned i......long
L!: unsigned long
q!: signed long long
Q!: unsigned long long
j,j!: intptr_t
J,J!: uintptr_t
//}
: エンディアン依存、整数サイズ非依存 (C99 の stdint.h にある厳密な幅を持つ整数型に適切)
//emlist{
s: int16_t
S: uint16_t
l: int32_t
L: uint32_t......素を含む配列を返します。
@param template pack テンプレート文字列
@return オブジェクトの配列
以下にあげるものは、Array#pack、String#unpack、String#unpack1
のテンプレート文字の一覧です。テンプレート文字は後に「長さ... -
Object
# enum _ for(method = :each , *args) -> Enumerator (6207.0) -
Enumerator.new(self, method, *args) を返します。
...Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable......def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end... -
Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator (6207.0) -
Enumerator.new(self, method, *args) を返します。
...Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable......def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end... -
Object
# to _ enum(method = :each , *args) -> Enumerator (6207.0) -
Enumerator.new(self, method, *args) を返します。
...Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable......def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end...