別のキーワード
ライブラリ
- ビルトイン (235)
-
minitest
/ unit (1)
クラス
- BasicObject (24)
- Exception (8)
- Method (80)
- Module (12)
- Object (12)
- Proc (62)
- Thread (24)
- TracePoint (7)
- UnboundMethod (6)
モジュール
キーワード
- << (14)
- === (20)
- >> (14)
- [] (24)
-
add
_ trace _ func (12) -
assert
_ send (1) - bind (6)
- curry (22)
-
instance
_ eval (24) -
instance
_ method (12) - parameters (7)
-
set
_ trace _ func (12) -
singleton
_ method (12) - yield (12)
検索結果
先頭5件
-
Method
# call(*args) -> object (15133.0) -
メソッドオブジェクトに封入されているメソッドを起動します。
...@param args self に渡される引数。
@see UnboundMethod#bind_call
@see spec/safelevel
//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "foo called......せん。
@param args self に渡される引数。
@see UnboundMethod#bind_call
//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "foo called with arg 2... -
Method
# call(*args) { . . . } -> object (15133.0) -
メソッドオブジェクトに封入されているメソッドを起動します。
...@param args self に渡される引数。
@see UnboundMethod#bind_call
@see spec/safelevel
//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "foo called......せん。
@param args self に渡される引数。
@see UnboundMethod#bind_call
//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "foo called with arg 2... -
Method
# call(*args) -> object (15127.0) -
メソッドオブジェクトに封入されているメソッドを起動します。
...ません。
@param args self に渡される引数。
@see spec/safelevel
//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "foo called with arg 2"
//}... -
Method
# call(*args) { . . . } -> object (15127.0) -
メソッドオブジェクトに封入されているメソッドを起動します。
...ません。
@param args self に渡される引数。
@see spec/safelevel
//emlist[例][ruby]{
class Foo
def foo(arg)
"foo called with arg #{arg}"
end
end
m = Foo.new.method(:foo) # => #<Method: Foo#foo>
m[1] # => "foo called with arg 1"
m.call(2) # => "foo called with arg 2"
//}... -
Proc
# call(*arg) -> () (15126.0) -
手続きオブジェクトを実行してその結果を返します。
...else 0
end
end
p sign(-4) #=> -1
p sign(0) #=> 0
p sign(7) #=> 1
//}
また、以下のような syntactic sugar もあります。
//emlist[例][ruby]{
fib = lambda{|n|
case n
when 0 then 0
when 1 then 1
else
fib.(n - 2) + fib.(n - 1)
end
}
fib.(10) # => 55
//}
@param arg... -
TracePoint
# parameters -> [object] (6143.0) -
現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。 フォーマットは Method#parameters と同じです。
...hod#parameters と同じです。
@raise RuntimeError :call、:return、:b_call、:b_return、:c_call、:c_return
イベントのためのイベントフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(a, b = 2)
end
TracePoint.new(:call) do......|tp|
p tp.parameters # => a], [:opt, :b
end.enable do
foo(1)
end
//}
@see Method#parameters, UnboundMethod#parameters, Proc#parameters... -
MiniTest
:: Assertions # assert _ send(array , message = nil) -> true (6119.0) -
引数から、式を取り出して評価した結果が真の場合、検査にパスしたことになります。
...にパスしたことになります。
@param array 第一要素にレシーバとなる任意のオブジェクト、第二要素にメソッド名、
第三要素にパラメータをそれぞれ指定した配列を指定します。
@param message 検査に失敗した場合に......します。
文字列か Proc を指定します。Proc である場合は Proc#call した
結果を使用します。
@raise MiniTest::Assertion 取り出した式が偽を返す場合に発生します。
例:
assert_send([%w[foo bar baz], :include?, 'baz'])... -
Method
# <<(callable) -> Proc (161.0) -
self と引数を合成した Proc を返します。
...まず受け取った引数を callable に渡して呼び出し、
その戻り値を self に渡して呼び出した結果を返します。
Method#>> とは呼び出しの順序が逆になります。
@param callable Proc、Method、もしくは任意の call メソッドを持ったオブジ......list[例][ruby]{
def f(x)
x * x
end
def g(x)
x + x
end
# (3 + 3) * (3 + 3)
p (method(:f) << method(:g)).call(3) # => 36
//}
//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)......Hello, World!
Hello, Ruby!
TEXT
pipeline = method(:pp) << WordScanner << File.method(:read)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}
@see Proc#<<, Proc#>>... -
Method
# >>(callable) -> Proc (161.0) -
self と引数を合成した Proc を返します。
...を callable に渡して呼び出した結果を返します。
Method#<< とは呼び出しの順序が逆になります。
@param callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。
//emlist[例][ruby]{
def f(x)
x * x
end
def g(x)
x + x
end......# (3 * 3) + (3 * 3)
p (method(:f) >> method(:g)).call(3) # => 18
//}
//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT
pipeline = File.method(... -
Proc
# <<(callable) -> Proc (149.0) -
self と引数を合成した Proc を返します。
...、まず受け取った引数を callable に渡して呼び出し、
その戻り値を self に渡して呼び出した結果を返します。
Proc#>> とは呼び出しの順序が逆になります。
@param callable Proc、Method、もしくは任意の call メソッドを持ったオブ......oc { |x| x * x }
g = proc { |x| x + x }
# (3 + 3) * (3 + 3)
p (f << g).call(3) # => 36
//}
//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT......pipeline = proc { |data| puts "word count: #{data.size}" } << WordScanner << File.method(:read)
pipeline.call('testfile') # => word count: 4
//}
@see Method#<<, Method#>>... -
Proc
# >>(callable) -> Proc (149.0) -
self と引数を合成した Proc を返します。
...数を self に渡して呼び出し、
その戻り値を callable に渡して呼び出した結果を返します。
Proc#<< とは呼び出しの順序が逆になります。
@param callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。
//emlist[例......oc { |x| x * x }
g = proc { |x| x + x }
# (3 * 3) + (3 * 3)
p (f >> g).call(3) # => 18
//}
//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT......pipeline = proc { |fname| File.read(fname) } >> WordScanner >> method(:p)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}
@see Method#<<, Method#>>... -
BasicObject
# instance _ eval {|obj| . . . } -> object (79.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...ソッドは見えません。
これは、トップレベルの定数が Object 以下に作成されるためです。
@param expr 評価する文字列です。
@param filename 文字列を指定します。ファイル filename に文字列 expr が
書かれているかのよ......うに実行されます。スタックトレースの
表示などを差し替えることができます。
@param lineno 整数を指定します。行番号 lineno から文字列 expr が書かれているかのように実行されます。
スタックトレー......示などを差し替えることができます。
//emlist[例][ruby]{
class Foo
def initialize data
@key = data
end
private
def do_fuga
p 'secret'
end
end
some = Foo.new 'XXX'
some.instance_eval{p @key} #=> "XXX"
some.instance_eval{do_fuga } #=> "secret" # private メソッド... -
BasicObject
# instance _ eval(expr , filename = "(eval)" , lineno = 1) -> object (79.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...ソッドは見えません。
これは、トップレベルの定数が Object 以下に作成されるためです。
@param expr 評価する文字列です。
@param filename 文字列を指定します。ファイル filename に文字列 expr が
書かれているかのよ......うに実行されます。スタックトレースの
表示などを差し替えることができます。
@param lineno 整数を指定します。行番号 lineno から文字列 expr が書かれているかのように実行されます。
スタックトレー......示などを差し替えることができます。
//emlist[例][ruby]{
class Foo
def initialize data
@key = data
end
private
def do_fuga
p 'secret'
end
end
some = Foo.new 'XXX'
some.instance_eval{p @key} #=> "XXX"
some.instance_eval{do_fuga } #=> "secret" # private メソッド... -
Method
# curry -> Proc (49.0) -
self を元にカリー化した Proc を返します。
...。
@param arity 引数の個数を指定します。可変長の引数を指定できるメソッドを
カリー化する際には必ず指定する必要があります。
//emlist[例][ruby]{
def foo(a,b,c)
[a, b, c]
end
proc = self.method(:foo).curry
proc2 = proc.call(1, 2)......#=> #<Proc>
proc2.call(3) #=> [1,2,3]
def vararg(*args)
args
end
proc = self.method(:vararg).curry(4)
proc2 = proc.call(:x) #=> #<Proc>
proc3 = proc2.call(:y, :z) #=> #<Proc>
proc3.call(:a) #=> [:x, :y, :z, :a]
//}
@see Proc#curry...