るりまサーチ

最速Rubyリファレンスマニュアル検索!
465件ヒット [301-400件を表示] (0.084秒)

別のキーワード

  1. argf.class each_line
  2. argf.class each
  3. argf.class lines
  4. class new
  5. argf.class readline

検索結果

<< < ... 2 3 4 5 > >>

Module#public_method_defined?(name, inherit=true) -> bool (25.0)

インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が public であるときに true を返します。 そうでなければ false を返します。

... include したモジュールで
定義されたメソッドも対象になります。

@see Module#method_defined?, Module#private_method_defined?, Module#protected_method_defined?

//emlist[例][ruby]{
module A
def method1() end
end
class
B
protected
def method2() end
end
class
C...
...< B
include
A
def method3() end
end

A.method_defined? :method1 #=> true
C.public_method_defined? "method1" #=> true
C.public_method_defined? "method1", true #=> true
C.public_method_defined? "method1", false #=> true
C.public_method_defined? "method2" #=> fal...

UnboundMethod#bind(obj) -> Method (25.0)

self を obj にバインドした Method オブジェクトを生成して返します。

...オブジェクトである場合に発生します

//emlist[例][ruby]{
# クラスのインスタンスメソッドの UnboundMethod の場合
class
Foo
def foo
"foo"
end
end

# UnboundMethod `m' を生成
p m = Foo.instance_method(:foo) # => #<UnboundMethod: Foo#foo>

# Foo のインス...
...生成
p m.bind(Foo.new) # => #<Method: Foo#foo>

# Foo のサブクラス Bar のインスタンスをレシーバとする Method
class
Bar < Foo
end
p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>


# モジュールのインスタンスメソッドの UnboundMethod の...
...を生成
p m = Foo.instance_method(:foo) # => #<UnboundMethod: Foo#foo>

# Foo をインクルードしたクラス Bar のインスタンスをレシーバと
# する Method オブジェクトを生成
class
Bar
include
Foo
end
p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>
//}...
..._method(:foo) # => #<UnboundMethod: Foo#foo>

# Foo をインクルードしたクラス Bar のインスタンスをレシーバと
# する Method オブジェクトを生成
class
Bar
include
Foo
end
p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>
//}

@see UnboundMethod#bind_call...

ERB#def_module(methodname=&#39;erb&#39;) -> Module (13.0)

変換した Ruby スクリプトをメソッドとして定義した無名のモジュールを返します。

...ッド名

//emlist[例][ruby]{
require 'erb'
filename = 'example.rhtml'
erb = ERB.new("test1<%= arg1 %>\ntest2<%= arg2 %>\n")
erb.filename = filename
MyModule = erb.def_module('render(arg1, arg2)')
class
MyClass
include
MyModule
end
print MyClass.new.render('foo', 123)
# test1foo
# test2123
//}...

Enumerable#each_entry -> Enumerator (13.0)

ブロックを各要素に一度ずつ適用します。

...ます。

一要素として複数の値が渡された場合はブロックには配列として渡されます。

//emlist[例][ruby]{
class
Foo
include
Enumerable
def each
yield 1
yield 1,2
end
end
Foo.new.each_entry{|o| print o, " -- "}
# => 1 -- [1, 2] --
//}

ブロックを省...

Enumerable#each_entry {|obj| block} -> self (13.0)

ブロックを各要素に一度ずつ適用します。

...ます。

一要素として複数の値が渡された場合はブロックには配列として渡されます。

//emlist[例][ruby]{
class
Foo
include
Enumerable
def each
yield 1
yield 1,2
end
end
Foo.new.each_entry{|o| print o, " -- "}
# => 1 -- [1, 2] --
//}

ブロックを省...

絞り込み条件を変える

REXML::StreamListener#entitydecl(content) -> () (13.0)

DTDの実体宣言をパースしたときに呼び出されるコールバックメソッドです。

...EN" "http://www.textuality.com/boilerplate/OpenHatch.xml">
<!ENTITY hatch-pic SYSTEM "../grafix/OpenHatch.gif" NDATA gif>
]>
<root />
EOS

class
Listener
include
REXML::StreamListener
def entitydecl(content); p content; end
end
REXML::Parsers::StreamParser.new(xml, Listener.new).parse
# >> ["YN"...

TSort#each_strongly_connected_component -> Enumerator (13.0)

TSort#strongly_connected_components メソッドのイテレータ版です。 obj.each_strongly_connected_component は obj.strongly_connected_components.each に似ていますが、 ブロックの評価中に obj が変更された場合は予期しない結果になる ことがあります。

...なる
ことがあります。

each_strongly_connected_component は nil を返します。

//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

non_sort = {1=>[2], 2=>[...

TSort#each_strongly_connected_component {|nodes| ...} -> nil (13.0)

TSort#strongly_connected_components メソッドのイテレータ版です。 obj.each_strongly_connected_component は obj.strongly_connected_components.each に似ていますが、 ブロックの評価中に obj が変更された場合は予期しない結果になる ことがあります。

...なる
ことがあります。

each_strongly_connected_component は nil を返します。

//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

non_sort = {1=>[2], 2=>[...

TSort#each_strongly_connected_component_from(node, id_map={}, stack=[]) -> Enumerator (13.0)

node から到達可能な強連結成分についてのイテレータです。

...びません。

@param node ノードを指定します。

//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

non_sort = {1=>[2], 2=>[...
<< < ... 2 3 4 5 > >>