種類
ライブラリ
クラス
- BasicObject (24)
- Exception (8)
-
Fiddle
:: Closure :: BlockCaller (12) -
Fiddle
:: Function (12) -
Gem
:: Requirement (12) - Hash (12)
- Logger (24)
- Method (115)
- Module (24)
- Object (24)
- Set (24)
- Symbol (12)
- SystemCallError (12)
- Thread (42)
-
Thread
:: Backtrace :: Location (48) - TracePoint (130)
- UnboundMethod (18)
モジュール
- Enumerable (48)
- Kernel (124)
-
RubyVM
:: AbstractSyntaxTree (10) - TSort (93)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - << (7)
- === (20)
- >> (7)
- Location (12)
- Method (12)
- MonitorMixin (12)
-
NEWS for Ruby 2
. 2 . 0 (11) -
NEWS for Ruby 2
. 3 . 0 (10) - OPS (12)
- SystemCallError (12)
- UnboundMethod (12)
- [] (12)
- abort (12)
-
absolute
_ path (12) -
add
_ trace _ func (12) -
base
_ label (12) - bind (6)
-
bind
_ call (12) - binding (12)
-
callee
_ id (12) - caller (36)
-
caller
_ locations (24) - clone (12)
- curry (22)
-
default
_ proc (12) -
defined
_ class (12) - detect (24)
- divide (24)
-
each
_ strongly _ connected _ component (23) -
each
_ strongly _ connected _ component _ from (23) - event (12)
- fail (12)
- find (24)
- formatter (12)
- formatter= (12)
- inspect (24)
-
instance
_ eval (24) -
instance
_ method (12) - lineno (12)
- method (12)
-
method
_ id (12) - new (24)
- open (4)
- parameters (7)
-
parse
_ file (10) - path (12)
- raise (12)
-
rb
_ call _ super (12) - rdoc (12)
-
rdoc
/ parser / c (12) -
report
_ on _ exception (9) -
report
_ on _ exception= (9) -
ruby 1
. 6 feature (12) -
ruby 1
. 8 . 4 feature (12) -
ruby 1
. 9 feature (12) -
ruby2
_ keywords (12) - self (3)
-
set
_ trace _ func (24) -
singleton
_ method (12) -
strongly
_ connected _ components (12) -
super
_ method (11) - syscall (12)
-
to
_ proc (24) -
to
_ s (12) - trace (12)
- tsort (24)
-
tsort
_ each (23) - 制御構造 (12)
- 正規表現 (12)
検索結果
先頭5件
-
tsort (26132.0)
-
tsort はトポロジカルソートと強連結成分に関するモジュールを提供します。
...tsort はトポロジカルソートと強連結成分に関するモジュールを提供します。
=== Example
//emlist[][ruby]{
require 'tsort'
class Hash
include TSort
alias tsort_each_node each_key
def tsort_each_child(node, &block)
fetch(node).each(&block)
end
end
{1=>[2, 3],......=>[]}.tsort
#=> [3, 2, 1, 4]
{1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components
#=> [[4], [2, 3], [1]]
//}
=== より現実的な例
非常に単純な `make' に似たツールは以下のように実装できます。
//emlist[][ruby]{
require 'tsort'
class Make
def initialize......outputs.map {|f| File.mtime f}.min
rescue Errno::ENOENT
outputs_time = nil
end
if outputs_time == nil ||
inputs_time != nil && outputs_time <= inputs_time
sleep 1 if inputs_time != nil && inputs_time.to_i == Time.now.to_i
block.call... -
Fiddle
:: Function # call(*args) -> Integer|DL :: CPtr|nil (21231.0) -
関数を呼び出します。
...関数を呼び出します。
Fiddle::Function.new で指定した引数と返り値の型に基いて
Ruby のオブジェクトを適切に C のデータに変換して C の関数を呼び出し、
その返り値を Ruby のオブジェクトに変換して返します。
引数の変換は......Fiddle::Pointer は保持している C ポインタに変換されます。
文字列であればその先頭ポインタになります。
IO オブジェクトであれば FILE* が渡されます。
整数であればそれがアドレスとみなされます。
to_ptr を持ってい......ddle::Pointer に
変換したものを用います。
to_i を持っているならば、それを呼びだし結果の整数を
アドレスと見なします
: (unsigned) char/short/int/long/long long
Ruby の整数を C の整数に変換します。
: double/float
Ruby の整数... -
Method
# call(*args) -> object (18220.0) -
メソッドオブジェクトに封入されているメソッドを起動します。
...f に渡される引数。
@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 with arg 2"
//}......@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 (18220.0) -
メソッドオブジェクトに封入されているメソッドを起動します。
...f に渡される引数。
@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 with arg 2"
//}......@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 (18214.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 (18214.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"
//}... -
Kernel
. # caller _ locations(range) -> [Thread :: Backtrace :: Location] | nil (12306.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレームの個数を指定します。
@pa......mlist[例][ruby]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end
def test2(start, length)
test1(start, length)
end
def test3(start, length)
test2(start, length)
end
caller_locations # => []
test3(1....../Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test3(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9... -
Kernel
. # caller _ locations(start = 1 , length = nil) -> [Thread :: Backtrace :: Location] | nil (12306.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレームの個数を指定します。
@pa......mlist[例][ruby]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end
def test2(start, length)
test1(start, length)
end
def test3(start, length)
test2(start, length)
end
caller_locations # => []
test3(1....../Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test3(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9... -
SystemCallError (12016.0)
-
Ruby の実装に用いられているシステムコールまたは一部の C 言語関数が失敗した時に発生する例外です。 システムコールの失敗した原因を表すエラーコードを保持します。
...Ruby の実装に用いられているシステムコールまたは一部の C 言語関数が失敗した時に発生する例外です。
システムコールの失敗した原因を表すエラーコードを保持します。
多くの場合、実際には SystemCallError そのものでは... -
UnboundMethod
# bind _ call(recv , *args) -> object (9226.0) -
self を recv に bind して args を引数として呼び出します。
...self を recv に bind して args を引数として呼び出します。
self.bind(recv).call(*args) と同じ意味です。
//emlist[][ruby]{
puts Kernel.instance_method(:inspect).bind_call(BasicObject.new) # => #<BasicObject:0x000055c65e8ea7b8>
//}
@see UnboundMethod#bind, Method#call... -
UnboundMethod
# bind _ call(recv , *args) { . . . } -> object (9226.0) -
self を recv に bind して args を引数として呼び出します。
...self を recv に bind して args を引数として呼び出します。
self.bind(recv).call(*args) と同じ意味です。
//emlist[][ruby]{
puts Kernel.instance_method(:inspect).bind_call(BasicObject.new) # => #<BasicObject:0x000055c65e8ea7b8>
//}
@see UnboundMethod#bind, Method#call... -
Method
# super _ method -> Method | nil (9218.0) -
self 内で super を実行した際に実行されるメソッドを Method オブジェ クトにして返します。
...Method オブジェ
クトにして返します。
@see UnboundMethod#super_method
//emlist[例][ruby]{
class Super
def foo
"superclass method"
end
end
class Sub < Super
def foo
"subclass method"
end
end
m = Sub.new.method(:foo) # => #<Method: Sub#foo>
m.call # => "subclass metho......d"
m.super_method # => #<Method: Super#foo>
m.super_method.call # => "superclass method"
//}...