るりまサーチ

最速Rubyリファレンスマニュアル検索!
8713件ヒット [1-100件を表示] (0.102秒)
トップページ > クエリ:i[x] > クエリ:h[x] > ライブラリ:ビルトイン[x]

別のキーワード

  1. _builtin to_i
  2. fiddle to_i
  3. matrix elements_to_i
  4. matrix i
  5. csv to_i

モジュール

オブジェクト

キーワード

検索結果

<< 1 2 3 ... > >>

Object#define_singleton_method(symbol, method) -> Symbol (18426.0)

self に特異メソッド name を定義します。

...m symbol メソッド名を String または Symbol で指定します。

@param method Proc、Method あるいは UnboundMethod の
いずれかのインスタンスを指定します。

@return メソッド名を表す Symbol を返します。

//emlist[][ruby]{
class A
class <<...
...self
def class_name
to_s
end
end
end
A.define_singleton_method(:who_am_i) do
"I am: #{class_name}"
end
A.who_am_i # ==> "I am: A"

guy = "Bob"
guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
guy.hello #=> "Bob: Hello there!"
//}...

Enumerable#each_with_index(*args) {|item, index| ... } -> self (18414.0)

要素とそのインデックスをブロックに渡して繰り返します。

...ith_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。

@param args イテレータメソッド (each など) にそのまま渡されます。

//emlist[例][ruby]{
[5, 10, 15].each_with...
..._index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}

//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
//}

@see Enumerator#with_index...

Object#define_singleton_method(symbol) { ... } -> Symbol (18326.0)

self に特異メソッド name を定義します。

...m symbol メソッド名を String または Symbol で指定します。

@param method Proc、Method あるいは UnboundMethod の
いずれかのインスタンスを指定します。

@return メソッド名を表す Symbol を返します。

//emlist[][ruby]{
class A
class <<...
...self
def class_name
to_s
end
end
end
A.define_singleton_method(:who_am_i) do
"I am: #{class_name}"
end
A.who_am_i # ==> "I am: A"

guy = "Bob"
guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
guy.hello #=> "Bob: Hello there!"
//}...

Enumerable#each_with_index(*args) -> Enumerator (18314.0)

要素とそのインデックスをブロックに渡して繰り返します。

...ith_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。

@param args イテレータメソッド (each など) にそのまま渡されます。

//emlist[例][ruby]{
[5, 10, 15].each_with...
..._index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
//}

//emlist[引数ありの例][ruby]{
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
//}

@see Enumerator#with_index...

Enumerable#each_with_object(obj) -> Enumerator (18314.0)

与えられた任意のオブジェクトと要素をブロックに渡し繰り返し、最初に与えられたオブジェクトを返します。

...返します。

ブロックを省略した場合は Enumerator を返します。

@param obj 任意のオブジェクトを指定します。

//emlist[例][ruby]{
evens = (1..10).each_with_object([]) {|i, a| a << i*2 }
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}

@see Enumerator#with_object...

絞り込み条件を変える

Enumerable#each_with_object(obj) {|(*args), memo_obj| ... } -> object (18314.0)

与えられた任意のオブジェクトと要素をブロックに渡し繰り返し、最初に与えられたオブジェクトを返します。

...返します。

ブロックを省略した場合は Enumerator を返します。

@param obj 任意のオブジェクトを指定します。

//emlist[例][ruby]{
evens = (1..10).each_with_object([]) {|i, a| a << i*2 }
# => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
//}

@see Enumerator#with_object...

BasicObject#singleton_method_undefined(name) -> object (15302.0)

特異メソッドが Module#undef_method または undef により未定義にされた時にインタプリタから呼び出されます。

...thod または
undef により未定義にされた時にインタプリタから呼び出されます。

通常のメソッドの未定義に対するフックには
Module#method_undefined を使います。

@param name 未定義にされたメソッド名が Symbol で渡されます。

//emli...
...def singleton_method_undefined(name)
puts "singleton method \"#{name}\" was undefined"
end
end

obj = Foo.new
def obj.foo
end
def obj.bar
end

class << obj
undef_method :foo
end
obj.instance_eval {undef bar}

#=> singleton method "foo" was undefined
# singleton method "bar" was undefined
/...
.../}

@see Module#method_undefined,BasicObject#singleton_method_added,BasicObject#singleton_method_removed , d:spec/def#undef...

Encoding::Converter#finish -> String (15302.0)

変換処理を終了し、結果文字列の末尾を返します。 変換元の文字列の末尾がバイト列の途中で終わっていた場合、保持しているバイト列全てを返します。

...末尾
@raise Encoding::InvalidByteSequenceError 変換元のエンコーディングにお
いて不正なバイト列があった場合に発生します。

//emlist[][ruby]{
ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
p ec.convert("\u3042") #=> "\e$B$\""
p ec.finish...

String#each_codepoint {|codepoint| block } -> self (15302.0)

文字列の各コードポイントに対して繰り返します。

...ます。

//emlist[例][ruby]{
#coding:UTF-8
"hello わーるど".each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 12431, 12540, 12427, 12393]
"hello わーるど".encode('euc-jp').each_codepoint.to_a
# => [104, 101, 108, 108, 111, 32, 42223, 41404, 42219, 42185]
//}

@see String#codepoints...

String#each_line(rs = $/) {|line| ... } -> self (15302.0)

文字列中の各行に対して繰り返します。 行の区切りは rs に指定した文字列で、 そのデフォルト値は変数 $/ の値です。 各 line には区切りの文字列も含みます。

...す。
行の区切りは rs に指定した文字列で、
そのデフォルト値は変数 $/ の値です。
各 line には区切りの文字列も含みます。

rs に nil を指定すると行区切りなしとみなします。
rs に空文字列 "" を指定すると「パラグラフモ...
...

//emlist[例][ruby]{
"aa\nbb\ncc\n".each_line do |line|
p line
end
# => "aa\n"
# => "bb\n"
# => "cc\n"

p "aa\nbb\ncc\n".lines.to_a # => ["aa\n", "bb\n", "cc\n"]
p "aa\n".lines.to_a # => ["aa\n"]
p "".lines.to_a # => []

s = "aa\nbb\ncc\n"
p s.lines("\n")...
....to_a #=> ["aa\n", "bb\n", "cc\n"]
p s.lines("bb").to_a #=> ["aa\nbb", "\ncc\n"]
//}

@see String#lines...

絞り込み条件を変える

<< 1 2 3 ... > >>