るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

キーワード

検索結果

<< 1 2 > >>

ARGF.class#each_char -> Enumerator (32252.0)

レシーバに含まれる文字を一文字ずつブロックに渡して評価します。

...ーバに含まれる文字を一文字ずつブロックに渡して評価します。

このメソッドはスクリプトに指定した引数(Object::ARGV を参照) をファ
イル名とみなして、それらのファイルを連結した 1 つの仮想ファイルを表すオ
ブジェク...
...lename を使用します。

ブロックが与えられなかった場合は、Enumerator オブジェクトを生成し
て返します。

例:
# $ echo "line1\n" > test1.txt
# $ echo "line2\n" > test2.txt
# $ ruby test.rb test1.txt test2.txt

# test.rb
ARGF.each_char # => #<E...
...numerator: ARGF:each_char>
ARGF.each_char{|e|p e}

# => "l"
# "i"
# "n"
# "e"
# "1"
# "\n"
# "l"
# "i"
# "n"
# "e"
# "2"
# "\n"

@see IO#each_char...

ARGF.class#each_char { |c| ... } -> self (32252.0)

レシーバに含まれる文字を一文字ずつブロックに渡して評価します。

...ーバに含まれる文字を一文字ずつブロックに渡して評価します。

このメソッドはスクリプトに指定した引数(Object::ARGV を参照) をファ
イル名とみなして、それらのファイルを連結した 1 つの仮想ファイルを表すオ
ブジェク...
...lename を使用します。

ブロックが与えられなかった場合は、Enumerator オブジェクトを生成し
て返します。

例:
# $ echo "line1\n" > test1.txt
# $ echo "line2\n" > test2.txt
# $ ruby test.rb test1.txt test2.txt

# test.rb
ARGF.each_char # => #<E...
...numerator: ARGF:each_char>
ARGF.each_char{|e|p e}

# => "l"
# "i"
# "n"
# "e"
# "1"
# "\n"
# "l"
# "i"
# "n"
# "e"
# "2"
# "\n"

@see IO#each_char...

String#each_char -> Enumerator (32216.0)

文字列の各文字に対して繰り返します。

...文字列の各文字に対して繰り返します。

たとえば、
//emlist[][ruby]{
"hello世界".each_char {|c| print c, ' ' }
//}
は次のように出力されます。
h e l l o 世 界

@see String#chars...

String#each_char {|cstr| block } -> self (32216.0)

文字列の各文字に対して繰り返します。

...文字列の各文字に対して繰り返します。

たとえば、
//emlist[][ruby]{
"hello世界".each_char {|c| print c, ' ' }
//}
は次のように出力されます。
h e l l o 世 界

@see String#chars...

IO#each_char -> Enumerator (32210.0)

self に含まれる文字を一文字ずつブロックに渡して評価します。

...self に含まれる文字を一文字ずつブロックに渡して評価します。

self は読み込み用にオープンされていなければなりません。

ブロックを省略した場合は各文字について繰り返す Enumerator を返します。

@raise IOError self が読...
...み込み用にオープンされていない場合に発生します。

f = File.new("testfile")
f.each_char {|c| print c, ' ' } #=> #<File:testfile>...

絞り込み条件を変える

IO#each_char {|c| ... } -> self (32210.0)

self に含まれる文字を一文字ずつブロックに渡して評価します。

...self に含まれる文字を一文字ずつブロックに渡して評価します。

self は読み込み用にオープンされていなければなりません。

ブロックを省略した場合は各文字について繰り返す Enumerator を返します。

@raise IOError self が読...
...み込み用にオープンされていない場合に発生します。

f = File.new("testfile")
f.each_char {|c| print c, ' ' } #=> #<File:testfile>...

Module#instance_method(name) -> UnboundMethod (14126.0)

self のインスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

...self のインスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

@param name メソッド名を Symbol または String で指定します。

@raise NameError self に存在しないメソッドを指定した場合に発生します。

@see Module#publ...
...tance_method, Object#method

//emlist[例][ruby]{
class Interpreter
def do_a() print "there, "; end
def do_d() print "Hello "; end
def do_e() print "!\n"; end
def do_v() print "Dave"; end
Dispatcher = {
"a" => instance_method(:do_a),
"d" => instance_method(:do_d),
"e" =...
...> instance_method(:do_e),
"v" => instance_method(:do_v)
}
def interpret(string)
string.each_char {|b| Dispatcher[b].bind(self).call }
e
nd
e
nd

interpreter = Interpreter.new
interpreter.interpret('dave')
# => Hello there, Dave!
//}...

String#each_grapheme_cluster -> Enumerator (14114.0)

文字列の書記素クラスタに対して繰り返します。

...ng#each_char と違って、
Unicode Standard Annex #29 (https://unicode.org/reports/tr29/)
で定義された書記素クラスタに対して繰り返します。

//emlist[例][ruby]{
"a\u0300".each_char.to_a.size # => 2
"a\u0300".each_grapheme_cluster.to_a.size # => 1
//}

@see String#grapheme_c...
...lusters...

String#each_grapheme_cluster {|grapheme_cluster| block } -> self (14114.0)

文字列の書記素クラスタに対して繰り返します。

...ng#each_char と違って、
Unicode Standard Annex #29 (https://unicode.org/reports/tr29/)
で定義された書記素クラスタに対して繰り返します。

//emlist[例][ruby]{
"a\u0300".each_char.to_a.size # => 2
"a\u0300".each_grapheme_cluster.to_a.size # => 1
//}

@see String#grapheme_c...
...lusters...

Enumerator::Lazy#collect_concat {|item| ... } -> Enumerator::Lazy (14108.0)

ブロックの実行結果をひとつに繋げたものに対してイテレートするような Enumerator::Lazy のインスタンスを返します。

...行結果をひとつに繋げたものに対してイテレートするような
E
numerator::Lazy のインスタンスを返します。

//emlist[][ruby]{
["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force
#=> ["f", "o", "o", "b", "a", "r"]
//}

ブロックの返した値 x は、以下...
...* x が each および force メソッドを持つ (例:Enumerator::Lazy) とき

それ以外のときは、x は分解されず、そのままの値として使われます。

//emlist[][ruby]{
[{a:1}, {b:2}].lazy.flat_map {|i| i}.force
#=> [{:a=>1}, {:b=>2}]
//}

@raise ArgumentError ブロ...
...ックを指定しなかった場合に発生します。

@see Enumerable#flat_map...

絞り込み条件を変える

<< 1 2 > >>