るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

Module#===(obj) -> bool (26113.0)

指定された obj が self かそのサブクラスのインスタンスであるとき真を返します。 また、obj が self をインクルードしたクラスかそのサブクラスのインスタンスである場合にも 真を返します。上記のいずれでもない場合に false を返します。

...ではクラス、モジュールの所属関係をチェックすることになります。

//emlist[例][ruby]{
str = String.new
case str
when String # String === str を評価する
p true # => true
end
//}

@param obj 任意のオブジェクト

@see Object#kind_of?, Object#inst...

Method#===(*args) -> object (26107.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"
//}...
...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"
//}...

String#===(other) -> bool (23107.0)

other が文字列の場合、String#eql? と同様に文字列の内容を比較します。

...ば false を返します。

@param other 任意のオブジェクト
@return true か false

//emlist[例][ruby]{
stringlike = Object.new

def stringlike.==(other)
"string" == other
end

p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false

def stringlike.to_str...

Method#[](*args) -> object (11007.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"
//}...
...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 (11007.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"
//}...
...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 (11007.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"
//}...
...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"
//}...

Array#pack(template, buffer: String.new) -> String (8120.0)

配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。

...されます。
また、`#' から改行あるいはテンプレート文字列の最後まではコメントとみな
され無視されます。

===
整数のテンプレート文字のシステム依存性

各テンプレート文字の説明の中で、
short や long はシステムによら...
...nsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}

===
各テンプレート文字の説明

説明中、Array#pack と String#unpack で違いのあるものは `/' で区切って
「Array#pack の...
...タの幅の符号つき整数, エンディアンに依存)

: J

uintptr_t (ポインタの幅の符号なし整数, エンディアンに依存)

===
使用例

以下、pack/unpack の使用例の一部です。

pack を使用しなくても同じことができる場合はその例も載せて...

Object#<=>(other) -> 0 | nil (8029.0)

self === other である場合に 0 を返します。そうでない場合には nil を返します。

...self === other である場合に 0 を返します。そうでない場合には nil を返します。

//emlist[例][ruby]{
a = Object.new
b = Object.new
a <=> a # => 0
a <=> b # => nil
//}

@see Object#===...

Module#undef_method(*name) -> self (8025.0)

このモジュールのインスタンスメソッド name を未定義にします。

...か Symbol を指定します。

@raise NameError 指定したインスタンスメソッドが定義されていない場合に発生します。

===
「未定義にする」とは
このモジュールのインスタンスに対して name という
メソッドを呼び出すことを禁止す...
...'
end
end
class B < A
def ok
puts 'B'
end
end

B.new.ok # => B

# undef_method の場合はスーパークラスに同名のメソッドがあっても
# その呼び出しはエラーになる
class B
undef_method :ok
end
B.new.ok # => NameError

# remove_method の場合はスー...
...パークラスに同名のメソッドがあると
# それが呼ばれる
class B
remove_method :ok
end
B.new.ok # => A
//}

また、undef 文と undef_method の違いは、
メソッド名を String または Symbol で与えられることです。

//emlist[例][ruby]{
module M1
def foo...

Array#pack(template) -> String (8020.0)

配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。

...されます。
また、`#' から改行あるいはテンプレート文字列の最後まではコメントとみな
され無視されます。

===
整数のテンプレート文字のシステム依存性

各テンプレート文字の説明の中で、
short や long はシステムによら...
...nsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}

===
各テンプレート文字の説明

説明中、Array#pack と String#unpack で違いのあるものは `/' で区切って
「Array#pack の...
...タの幅の符号つき整数, エンディアンに依存)

: J

uintptr_t (ポインタの幅の符号なし整数, エンディアンに依存)

===
使用例

以下、pack/unpack の使用例の一部です。

pack を使用しなくても同じことができる場合はその例も載せて...

絞り込み条件を変える

Regexp#match(str, pos = 0) -> MatchData | nil (8013.0)

指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。

...st[例][ruby]{
reg = Regexp.new("foo")

if reg.match("foobar")
puts "match"
end
# => match

p reg.match("foobar") # => #<MatchData:0x29403fc>
p reg.match("bar") # => nil

p /(foo)(bar)(baz)/.match("foobarbaz").to_a.values_at(1,2,3) # => ["foo", "bar", "baz"]
//}

===
便利な使いかた
...

Regexp#match(str, pos = 0) {|m| ... } -> object | nil (8013.0)

指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。

...st[例][ruby]{
reg = Regexp.new("foo")

if reg.match("foobar")
puts "match"
end
# => match

p reg.match("foobar") # => #<MatchData:0x29403fc>
p reg.match("bar") # => nil

p /(foo)(bar)(baz)/.match("foobarbaz").to_a.values_at(1,2,3) # => ["foo", "bar", "baz"]
//}

===
便利な使いかた
...
<< 1 2 > >>