395件ヒット
[201-300件を表示]
(0.081秒)
種類
- インスタンスメソッド (322)
- モジュール関数 (40)
- クラス (22)
- 特異メソッド (11)
ライブラリ
- ビルトイン (395)
クラス
- Array (19)
- BasicObject (22)
- Enumerator (66)
-
Enumerator
:: Lazy (11) -
Enumerator
:: Yielder (11) - FrozenError (5)
- Method (28)
- Module (11)
- Object (88)
- Proc (6)
- Regexp (22)
- String (22)
モジュール
- Enumerable (22)
- Kernel (40)
キーワード
- Numeric (11)
- String (11)
- clone (11)
-
define
_ singleton _ method (22) - dup (11)
- each (44)
- extend (11)
- gets (11)
-
initialize
_ copy (11) - inspect (11)
- loop (18)
- match (22)
- methods (11)
- new (11)
- pack (19)
-
prepend
_ features (11) - readline (11)
- receiver (5)
-
singleton
_ method _ removed (11) -
singleton
_ method _ undefined (11) -
singleton
_ methods (11) -
sort
_ by (22) - sum (11)
-
to
_ s (11) - unpack (11)
-
with
_ object (22)
検索結果
先頭5件
-
Object
# define _ singleton _ method(symbol) { . . . } -> Symbol (8030.0) -
self に特異メソッド name を定義します。
...rn メソッド名を表す 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... -
Object
# define _ singleton _ method(symbol , method) -> Symbol (8030.0) -
self に特異メソッド name を定義します。
...rn メソッド名を表す 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... -
Object
# initialize _ copy(obj) -> object (8030.0) -
(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。
...w
class <<obj
attr_accessor :foo
def bar
:bar
end
end
def check(obj)
puts "instance variables: #{obj.inspect}"
puts "tainted?: #{obj.tainted?}"
print "singleton methods: "
begin
p obj.bar
rescue NameError
p $!
end
end
obj.foo = 1
obj.taint
check Object.new.send(:init......ruby]{
obj = Object.new
class <<obj
attr_accessor :foo
def bar
:bar
end
end
def check(obj)
puts "instance variables: #{obj.inspect}"
print "singleton methods: "
begin
p obj.bar
rescue NameError
p $!
end
end
obj.foo = 1
check Object.new.send(:initialize_copy, obj)... -
Enumerator
# with _ object(obj) -> Enumerator (8024.0) -
繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。
...だす enumeratorを作る
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end
to_three_with_string = to_three.with_object("foo")
to_three_with_string.each do |x,string|
puts "#{string}: #{x}"
end
# => foo:0
# => foo:1
# => foo:2
//}
@param obj 繰り返しの各要素に添... -
Enumerator
# with _ object(obj) {|(*args) , memo _ obj| . . . } -> object (8024.0) -
繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。
...だす enumeratorを作る
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end
to_three_with_string = to_three.with_object("foo")
to_three_with_string.each do |x,string|
puts "#{string}: #{x}"
end
# => foo:0
# => foo:1
# => foo:2
//}
@param obj 繰り返しの各要素に添... -
Kernel
. # gets(rs = $ / ) -> String | nil (8018.0) -
ARGFから一行読み込んで、それを返します。 行の区切りは引数 rs で指定した文字列になります。
...達した時、 nil を返します。
@raise Errno::EXXX 読み込みに失敗した場合に発生します。
//emlist[main.rb][ruby]{
ARGV << 'b.txt' << 'c.txt'
p gets #=> "hello\n"
p gets(nil) #=> "it\ncommon\n"
p gets("") #=> "ARGF\n\n"
p gets('、') #=> "# スクリプトに指定した引......"
p gets #=> "それらのファイルを連結した 1 つの仮想ファイルを表すオブジェクトです。\n"
p gets #=> nil
p readline # end of file reached (EOFError)
//}
//emlist[b.txt][ruby]{
hello
it
common
//}
//emlist[c.txt][ruby]{
ARGF
# スクリプトに指定した引数 (Obj... -
Kernel
. # loop -> Enumerator (8018.0) -
(中断されない限り)永遠にブロックの評価を繰り返します。 ブロックが指定されなければ、代わりに Enumerator を返します。
...代わりに Enumerator を返します。
//emlist[例][ruby]{
loop do
print "Input: "
line = gets
break if !line or line =~ /^qQ/
# ...
end
//}
与えられたブロック内で StopIteration を Kernel.#raise すると
ループを終了して Enumerator が最後に返した値を返......。
ループを終了させる場合、通常は break を使用してください。
//emlist[例][ruby]{
enum = Enumerator.new { |y|
y << "one"
y << "two"
:ok
}
result = loop {
puts enum.next
} # => :ok
//}
@return break の引数など、ループ脱出時の値を返します。... -
Kernel
. # loop { . . . } -> object | nil (8018.0) -
(中断されない限り)永遠にブロックの評価を繰り返します。 ブロックが指定されなければ、代わりに Enumerator を返します。
...代わりに Enumerator を返します。
//emlist[例][ruby]{
loop do
print "Input: "
line = gets
break if !line or line =~ /^qQ/
# ...
end
//}
与えられたブロック内で StopIteration を Kernel.#raise すると
ループを終了して Enumerator が最後に返した値を返......。
ループを終了させる場合、通常は break を使用してください。
//emlist[例][ruby]{
enum = Enumerator.new { |y|
y << "one"
y << "two"
:ok
}
result = loop {
puts enum.next
} # => :ok
//}
@return break の引数など、ループ脱出時の値を返します。... -
Kernel
. # readline(rs = $ / ) -> String (8018.0) -
ARGFから一行読み込んで、それを返します。 行の区切りは引数 rs で指定した文字列になります。
...します。
@raise EOFError readline でファイル末端(EOF)を検出すると発生します。
//emlist[例][ruby]{
# ---main.rb---
ARGV << 'b.txt' << 'c.txt'
p readline #=> "hello\n"
p readline(nil) #=> "it\ncommon\n"
p readline("") #=> "ARGF\n\n"
p readline('、') #=> "スクリプトに指......して、"
p readline #=> "それらのファイルを連結した 1 つの仮想ファイルを表すオブジェクトです。 \n"
p readline # end of file reached (EOFError)
# --- b.txt ---
hello
it
common
# --- c.txt ---
ARGF
# スクリプトに指定した引数 (Object::ARGV を参照) を... -
Object
# clone(freeze: true) -> object (8018.0) -
オブジェクトの複製を作成して返します。
...freeze されていないコピーを作成しようとしたときに発生します。
//emlist[][ruby]{
obj = "string"
obj.taint
def obj.fuga
end
obj.freeze
p(obj.equal?(obj)) #=> true
p(obj == obj) #=> true
p(obj.tainted?) #=> true
p(obj.frozen?)......には使えません。
//emlist[][ruby]{
obj = ["a","b","c"]
obj_d = obj.dup
obj_d[0] << "PLUS"
p obj #=> ["aPLUS", "b", "c"]
p obj_d #=> ["aPLUS", "b", "c"]
obj_m = Marshal.load(Marshal.dump(obj))
obj_m[1] << "PLUS"
p obj #=> ["aPLUS", "b", "c"]
p obj_m #=> ["aPLUS", "bPLUS", "c"]
//}......freeze されていないコピーを作成しようとしたときに発生します。
//emlist[][ruby]{
obj = "string"
obj.taint
def obj.fuga
end
obj.freeze
p(obj.equal?(obj)) #=> true
p(obj == obj) #=> true
p(obj.tainted?) #=> false
p(obj.frozen?)......ェクトの freeze されていないコピーを作成しようとしたときに発生します。
//emlist[][ruby]{
obj = "string"
def obj.fuga
end
obj.freeze
p(obj.equal?(obj)) #=> true
p(obj == obj) #=> true
p(obj.frozen?) #=> true
p(obj.respond_to?(:fuga)...