るりまサーチ

最速Rubyリファレンスマニュアル検索!
263件ヒット [1-100件を表示] (0.171秒)

別のキーワード

  1. _builtin to_r
  2. open3 pipeline_r
  3. matrix elements_to_r
  4. fileutils chmod_r
  5. fileutils cp_r

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 > >>

String#each_byte -> Enumerator (27321.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...

String#each_byte {|byte| ... } -> self (27321.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 (27321.0)

自身から 1 バイトずつ読み込み、整数 ch に変換し、それを引数として与えられたブロックを実行します。

...変換し、それを引数として与えられたブロックを実行します。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
r
equire "stringio"
a = StringIO.new("hoge")
a.each_byte{|ch| p ch }
#=> 104
# 111
# 103
# 101
//}

@see IO#each_byte...

StringIO#each_byte {|ch| ... } -> self (27221.0)

自身から 1 バイトずつ読み込み、整数 ch に変換し、それを引数として与えられたブロックを実行します。

...変換し、それを引数として与えられたブロックを実行します。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
r
equire "stringio"
a = StringIO.new("hoge")
a.each_byte{|ch| p ch }
#=> 104
# 111
# 103
# 101
//}

@see IO#each_byte...

StringIO#each_byte -> Enumerator (24321.0)

自身から 1 バイトずつ読み込み、整数 ch に変換し、それを引数として与えられたブロックを実行します。

...変換し、それを引数として与えられたブロックを実行します。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
r
equire "stringio"
a = StringIO.new("hoge")
a.each_byte{|ch| p ch }
#=> 104
# 111
# 103
# 101
//}

@see IO#each_byte...

絞り込み条件を変える

IO#each_byte -> Enumerator (24315.0)

IO の現在位置から 1 バイトずつ読み込み、それを整数として与え、ブロックを実行します。

...rator オブジェクトを返します。

バイナリ読み込みメソッドとして動作します。

@raise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例][ruby]{
IO.write("testfile", "aあ")
File.open("testfile") do |io|
io.each_byt...

StringIO#each_byte {|ch| ... } -> self (24221.0)

自身から 1 バイトずつ読み込み、整数 ch に変換し、それを引数として与えられたブロックを実行します。

...変換し、それを引数として与えられたブロックを実行します。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
r
equire "stringio"
a = StringIO.new("hoge")
a.each_byte{|ch| p ch }
#=> 104
# 111
# 103
# 101
//}

@see IO#each_byte...

Enumerable#first -> object | nil (12319.0)

Enumerable オブジェクトの最初の要素、もしくは最初の n 要素を返します。

...Enumerable オブジェクトの最初の要素、もしくは最初の n 要素を返します。

Enumerable オブジェクトが空の場合、引数を指定しない形式では 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) #=> []
//}...

Enumerable#first(n) -> Array (12219.0)

Enumerable オブジェクトの最初の要素、もしくは最初の n 要素を返します。

...Enumerable オブジェクトの最初の要素、もしくは最初の n 要素を返します。

Enumerable オブジェクトが空の場合、引数を指定しない形式では 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) #=> []
//}...

Object#to_enum(method = :each, *args) {|*args| ... } -> Enumerator (9419.0)

Enumerator.new(self, method, *args) を返します。

...Enumerator.new(self, method, *args) を返します。

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出...
...t[][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 r...
...epeat(n)
r
aise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
r
eturn to_enum(__method__, n) do
# size メソッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end...

絞り込み条件を変える

String#bytes -> [Integer] (9347.0)

文字列の各バイトを数値の配列で返します。(self.each_byte.to_a と同じです)

....each_byte.to_a と同じです)

//emlist[例][ruby]{
"str".bytes # => [115, 116, 114]
//}

ブロックが指定された場合は String#each_byte と同じように動作します。

Ruby
2.6 までは deprecated の警告が出ますが、Ruby 2.7 で警告は削除されました。

@see Str...
...ing#each_byte...
<< 1 2 3 > >>