132件ヒット
[1-100件を表示]
(0.054秒)
ライブラリ
- ビルトイン (132)
クラス
-
ARGF
. class (24) - Enumerator (36)
- Object (48)
モジュール
- Enumerable (24)
キーワード
-
enum
_ for (24) - first (24)
- next (12)
-
to
_ enum (24) -
with
_ index (24)
検索結果
先頭5件
-
ARGF
. class # each _ byte -> Enumerator (18221.0) -
ARGF の現在位置から 1 バイトずつ読み込み、それを整数として与え、ブロックを実行します。 ブロック引数byteは0..255のいずれかの整数です。
...を実行します。
ブロック引数byteは0..255のいずれかの整数です。
このメソッドはスクリプトに指定した引数(Object::ARGV を参照) をファ
イル名とみなして、それらのファイルを連結した 1 つの仮想ファイルを表すオ
ブジェク......現在位置の1バイトについてファイル名を得るには
ARGF.class#filename を使用します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを生成して返します。
例:
ARGF.each_byte.to_a # => [35, 32, ... 95, 10]
@see IO#each_byte... -
ARGF
. class # each _ byte { |byte| . . . } -> self (18221.0) -
ARGF の現在位置から 1 バイトずつ読み込み、それを整数として与え、ブロックを実行します。 ブロック引数byteは0..255のいずれかの整数です。
...を実行します。
ブロック引数byteは0..255のいずれかの整数です。
このメソッドはスクリプトに指定した引数(Object::ARGV を参照) をファ
イル名とみなして、それらのファイルを連結した 1 つの仮想ファイルを表すオ
ブジェク......現在位置の1バイトについてファイル名を得るには
ARGF.class#filename を使用します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを生成して返します。
例:
ARGF.each_byte.to_a # => [35, 32, ... 95, 10]
@see IO#each_byte... -
Object
# enum _ for(method = :each , *args) -> Enumerator (9113.0) -
Enumerator.new(self, method, *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]{
modu......each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}
@see Enumerator, Enumerator#size... -
Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator (9113.0) -
Enumerator.new(self, method, *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]{
modu......each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}
@see Enumerator, Enumerator#size... -
Object
# to _ enum(method = :each , *args) -> Enumerator (9113.0) -
Enumerator.new(self, method, *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]{
modu......each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}
@see Enumerator, Enumerator#size... -
Object
# to _ enum(method = :each , *args) {|*args| . . . } -> Enumerator (9113.0) -
Enumerator.new(self, method, *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]{
modu......each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}
@see Enumerator, Enumerator#size... -
Enumerator
# next -> object (220.0) -
「次」のオブジェクトを返します。
...str = "xyz"
enum = str.each_byte
str.bytesize.times do
puts enum.next
end
# => 120
# 121
# 122
//}
//emlist[例2][ruby]{
str = "xyz"
enum = str.each_byte
begin
puts enum.next while true
rescue StopIteration
puts "iteration reached at end"
end
# => 120
# 121......# 122
# iteration reached at end
puts enum.next
#=> 再度 StopIteration 例外が発生
//}
//emlist[例3: Kernel.#loop は StopIteration を捕捉します。][ruby]{
str = "xyz"
enum = str.each_byte
loop do
puts enum.next
end
# => 120
# 121
# 122
//}... -
Enumerable
# first -> object | nil (214.0) -
Enumerable オブジェクトの最初の要素、もしくは最初の n 要素を返します。
...引数を指定しない形式では nil を返します。
引数を指定する形式では、空の配列を返します。
@param n 取得する要素数。
//emlist[例][ruby]{
e = "abcd".each_byte
e.first #=> 97
e.first(2) #=> [97,98]
e = "".each_byte
e.first #=> nil
e.first(2) #=> []
//}... -
Enumerator
# with _ index(offset = 0) {|(*args) , idx| . . . } -> object (208.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
..."xyz"
enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [120, 0]
# [121, 1]
# [122, 2]
require "stringio"
StringIO.new("foo|bar|baz").each("|").with_index(1) {|s, i| p [s, i] }
# => ["foo|", 1]
# ["bar|", 2]...