るりまサーチ

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

別のキーワード

  1. object yield_self
  2. _builtin yield_self
  3. _builtin self
  4. tracepoint self
  5. codeobject document_self

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

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

継承関係にないクラス同士の比較では
nil を返します。

@param other 比較対象のモ...
...@raise TypeError other がクラスやモジュールではない場合に発生します。

//emlist[例][ruby]{
module Foo
end
class Bar
i
nclude 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
Ba...
...z > Qux # => nil

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

String#split(sep = $;, limit = 0) {|s| ... } -> self (12529.0)

第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。

...1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、
結果を文字列の配列で返します。
ブロックを指定すると、配列を返す代わりに分割した文字列で
ブロックを呼び出します。

第 1 引数 sep は以下の...
...
: 1 バイトの空白文字 ' '
先頭と末尾の空白を除いたうえで、空白文字列で分割する。
: nil
常に $; で分割する。 $; も nil の場合は、先頭と末尾の空白を除いたうえで、空白文字列で分割する。
: 空文字列 '' あるいは...
...

sep が正規表現で、かつその正規表現に括弧が含まれている場合には、
各括弧のパターンにマッチした文字列も配列に含まれます。
括弧が複数ある場合は、マッチしたものだけが配列に含まれます。

第 2 引数 limit は以...

String#split(sep = $;, limit = 0) -> [String] (12429.0)

第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。

...1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、
結果を文字列の配列で返します。
ブロックを指定すると、配列を返す代わりに分割した文字列で
ブロックを呼び出します。

第 1 引数 sep は以下の...
...
: 1 バイトの空白文字 ' '
先頭と末尾の空白を除いたうえで、空白文字列で分割する。
: nil
常に $; で分割する。 $; も nil の場合は、先頭と末尾の空白を除いたうえで、空白文字列で分割する。
: 空文字列 '' あるいは...
...

sep が正規表現で、かつその正規表現に括弧が含まれている場合には、
各括弧のパターンにマッチした文字列も配列に含まれます。
括弧が複数ある場合は、マッチしたものだけが配列に含まれます。

第 2 引数 limit は以...

Method#inspect -> String (12360.0)

self を読みやすい文字列として返します。

...
self
を読みやすい文字列として返します。

以下の形式の文字列を返します。

#<Method: klass1(klass2)#method> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクト...
...emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
i
nclude Foo
def bar
end
end

p
Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo>
p
Bar.new.method(:bar) # => #<Method: Bar#bar>
//}

klass1 と klass2 が同じ場合は以下の形式になります。
#<Met...
...hod: klass1#method> (形式2)

特異メソッドに対しては、
#<Method: obj.method> (形式3)
#<Method: klass1(klass2).method> (形式4)
という形式の文字列を返します。二番目の形式では klass1 はレシー...
...
self
を読みやすい文字列として返します。

以下の形式の文字列を返します。

#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクト...
...thod#source_location を表します。
source_location が nil の場合には付きません。

//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
i
nclude Foo
def bar(a, b)
end
end

p
Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p
Bar.new.method(...
...) # => #<Method: Bar#bar(a, b) test.rb:8>
//}

klass1 と klass2 が同じ場合は以下の形式になります。
#<Method: klass1#method() foo.rb:2> (形式2)

特異メソッドに対しては、
#<Method: obj.method() foo.rb:2> (形式3)
#<Method: klass1...

Time#<=>(other) -> -1 | 0 | 1 | nil (9300.0)

self と other の時刻を比較します。self の方が大きい場合は 1 を、等しい場合は 0 を、 小さい場合は -1 を返します。比較できない場合は、nil を返します。

...
self
と other の時刻を比較します。self の方が大きい場合は 1 を、等しい場合は 0 を、
小さい場合は -1 を返します。比較できない場合は、nil を返します。

@param other 自身と比較したい時刻を Time オブジェクトで指定します。...
...//emlist[][ruby]{
p
t = Time.local(2000) # => 2000-01-01 00:00:00 +0900
p
t2 = t + 2592000 # => 2000-01-31 00:00:00 +0900
p
t <=> t2 # => -1
p
t2 <=> t # => 1
//}

//emlist[][ruby]{
p
t = Time.local(2000) # => 2000-01-01 00:00:00 +0900
p
t2 = t + 0.1 # =>...
...2000-01-01 00:00:00 +0900
p
t.nsec # => 0
p
t2.nsec # => 100000000
p
t <=> t2 # => -1
p
t2 <=> t # => 1
p
t <=> t # => 0
//}...

絞り込み条件を変える

String#<=>(other) -> -1 | 0 | 1 | nil (9276.0)

self と other を ASCII コード順で比較して、 self が大きい時には 1、等しい時には 0、小さい時には -1 を返します。 このメソッドは Comparable モジュールのメソッドを実装するために使われます。

...
self
と other を ASCII コード順で比較して、
self
が大きい時には 1、等しい時には 0、小さい時には -1 を返します。
このメソッドは Comparable モジュールのメソッドを実装するために使われます。

other が文字列でない場合、
othe...
...other.<=> が定義されていれば
0 - (other <=> self) の結果を返します。
そうでなければ nil を返します。

@param other 文字列
@return 比較結果の整数か nil

//emlist[例][ruby]{
p
"aaa" <=> "xxx" # => -1
p
"aaa" <=> "aaa" # => 0
p
"xxx" <=> "aaa"...
...# => 1

p
"string" <=> "stringAA" # => -1
p
"string" <=> "string" # => 0
p
"stringAA" <=> "string" # => 1
//}...

String#<<(other) -> self (9267.0)

self に文字列 other を破壊的に連結します。 other が 整数である場合は other.chr(self.encoding) 相当の文字を末尾に追加します。

...
self
に文字列 other を破壊的に連結します。
other が 整数である場合は other.chr(self.encoding) 相当の文字を末尾に追加します。

self
を返します。

@param other 文字列もしくは 0 以上の整数

//emlist[例][ruby]{
str = "string"
str.concat "XXX"...
...
p
str # => "stringXXX"

str << "YYY"
p
str # => "stringXXXYYY"

str << 65 # 文字AのASCIIコード
p
str # => "stringXXXYYYA"
//}...

File::Stat#<=>(o) -> Integer | nil (9236.0)

ファイルの最終更新時刻を比較します。self が other よりも 新しければ正の数を、等しければ 0 を古ければ負の数を返します。 比較できない場合は nil を返します。

...self が other よりも
新しければ正の数を、等しければ 0 を古ければ負の数を返します。
比較できない場合は nil を返します。

@param o File::Stat のインスタンスを指定します。

//emlist[][ruby]{
require 'tempfile' # for Tempfile

fp1 = Tempfile....
...open("first")
fp1.print "古い方\n"
sleep(1)
fp2 = Tempfile.open("second")
fp2.print "新しい方\n"

p
File::Stat.new(fp1.path) <=> File::Stat.new(fp2.path) #=> -1
p
File::Stat.new(fp2.path) <=> File::Stat.new(fp1.path) #=> 1
p
File::Stat.new(fp1.path) <=> fp2.path #=> nil
//}...

RubyVM::InstructionSequence#path -> String (9236.0)

self が表す命令シーケンスの相対パスを返します。

...
self
が表す命令シーケンスの相対パスを返します。

self
の作成時に指定した文字列を返します。self を文字列から作成していた
場合は "<compiled>" を返します。

例1:irb で実行した場合

i
seq = RubyVM::InstructionSequence.compile('num = 1...
...=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
i
seq.path
# => "<compiled>"

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/method.rb
def hello
p
uts "hello, world"
end

# irb
> iseq = RubyVM::InstructionSequence.compile_file('method.rb')
> ise...
...q.path # => "method.rb"

@see RubyVM::InstructionSequence#absolute_path...

Complex#<=>(other) -> -1 | 0 | 1 | nil (9234.0)

self の虚部がゼロで other が実数の場合、 self の実部の <=> メソッドで other と比較した結果を返します。 other が Complex で虚部がゼロの場合も同様です。

...
self
の虚部がゼロで other が実数の場合、
self
の実部の <=> メソッドで other と比較した結果を返します。
other が Complex で虚部がゼロの場合も同様です。

その他の場合は nil を返します。

@param other 自身と比較する数値

//emlis...
...t[例][ruby]{
Complex(2, 3) <=> Complex(2, 3) #=> nil
Complex(2, 3) <=> 1 #=> nil
Complex(2) <=> 1 #=> 1
Complex(2) <=> 2 #=> 0
Complex(2) <=> 3 #=> -1
//}...

絞り込み条件を変える

RubyVM::InstructionSequence#absolute_path -> String | nil (9230.0)

self が表す命令シーケンスの絶対パスを返します。

...
self
が表す命令シーケンスの絶対パスを返します。

self
を文字列から作成していた場合は nil を返します。

例1:irb で実行した場合

i
seq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
i
...
...te_path
# => nil

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/method.rb
def hello
p
uts "hello, world"
end

# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.absolute_path # => "/tmp/method.rb"

@see RubyVM::Instruction...
...Sequence#path...
<< 1 2 3 ... > >>