るりまサーチ

最速Rubyリファレンスマニュアル検索!
588件ヒット [1-100件を表示] (0.056秒)

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Module#<(other) -> bool | nil (18167.0)

比較演算子。self が other の子孫である場合、 true を返します。 self が other の先祖か同一のクラス/モジュールである場合、false を返します。

...//emlist[例][ruby]{
module Foo
end
class
Bar
include Foo
end
class
Baz < Bar
end
class
Qux
end
p Bar < Foo # => true
p Baz < Bar # => true
p Baz < Foo # => true
p Baz < Qux # => nil
p Baz > Qux # => nil

p Foo < Object.new # => in `<': compared with non class/module (TypeErr...

Class#subclasses -> [Class] (15256.0)

自身が直接のスーパークラスになっている(特異クラスを除く)クラスの配列を返します。 返り値の配列の順序は未定義です。

...を除く)クラスの配列を返します。
返り値の配列の順序は未定義です。

//emlist[例][ruby]{
class
A; end
class
B < A; end
class
C < B; end
class
D < A; end

A.subclasses # => [D, B]
B.subclasses # => [C]
C.subclasses # => []
//}

@see Class#superclass...

Class#superclass -> Class | nil (15238.0)

自身のスーパークラスを返します。

...][ruby]{
File.superclass #=> IO
IO.superclass #=> Object
class
Foo; end
class
Bar < Foo; end
Bar.superclass #=> Foo
Object.superclass #=> BasicObject
//}

ただし BasicObject.superclass は nil を返します。

//emlist[例][ruby]{
BasicObject.superclass #...
...=> nil
//}

@see Class#subclasses...

Class#inherited(subclass) -> () (9149.0)

クラスのサブクラスが定義された時、新しく生成されたサブクラスを引数 にインタプリタから呼び出されます。このメソッドが呼ばれるタイミングは クラス定義文の実行直前です。

...@param subclass プログラム内で新たに定義された自身のサブクラスです。

//emlist[例][ruby]{
class
Foo
def Foo.inherited(subclass)
puts "class \"#{self}\" was inherited by \"#{subclass}\""
end
end
class
Bar < Foo
puts "executing class body"
end

# => class "Foo" was...
...inherited by "Bar"
# executing class body
//}...

Module#class_variables(inherit = true) -> [Symbol] (6144.0)

クラス/モジュールに定義されているクラス変数の名前の配列を返します。

...ジュールのクラス変数を含みます。

//emlist[例][ruby]{
class
One
@@var1 = 1
end
class
Two < One
@@var2 = 2
end
One.class_variables # => [:@@var1]
Two.class_variables # => [:@@var2, :@@var1]
Two.class_variables(false) # => [:@@var2]
//}

@see Module.constants,...

絞り込み条件を変える

Method#<<(callable) -> Proc (6131.0)

self と引数を合成した Proc を返します。

...st[例][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#>>...

Module#<=>(other) -> Integer | nil (6131.0)

self と other の継承関係を比較します。

...のクラスやモジュール

//emlist[例][ruby]{
module Foo
end
class
Bar
include Foo
end
class
Baz < Bar
end
class
Qux
end
p Bar <=> Foo # => -1
p Baz <=> Bar # => -1
p Baz <=> Foo # => -1
p Baz <=> Qux # => nil
p Qux <=> Baz # => nil

p Baz <=> Object.new # => nil
//}...

Proc#<<(callable) -> Proc (6125.0)

self と引数を合成した Proc を返します。

...//emlist[例][ruby]{
f = proc { |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#>>...

Module#ancestors -> [Class, Module] (126.0)

クラス、モジュールのスーパークラスとインクルードしているモジュール を優先順位順に配列に格納して返します。

...るモジュール
を優先順位順に配列に格納して返します。

//emlist[例][ruby]{
module Foo
end
class
Bar
include Foo
end
class
Baz < Bar
p ancestors
p included_modules
p superclass
end
# => [Baz, Bar, Foo, Object, Kernel, BasicObject]
# => [Foo, Kernel]
# => Bar
//}

@see...

Rake::TaskManager#intern(task_class, task_name) -> Rake::Task (126.0)

タスクを検索します。

...am task_class タスクのクラスを指定します。

@param task_name タスクの名前を指定します。

//emlist[][ruby]{
# Rakefile での記載例とする

task default: :test_rake_app

task :test_rake_app do |task|
task.application.intern(Rake::Task, "test_rake_app") # => <Rake::Ta...
...sk test_rake_app => []>
task.application.intern(Rake::Task, "sample_task") # => <Rake::Task sample_task => []>
end
//}...

絞り込み条件を変える

<< 1 2 3 ... > >>