るりまサーチ

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

別のキーワード

  1. string []=
  2. string slice
  3. string slice!
  4. string []
  5. string gsub

ライブラリ

キーワード

検索結果

<< < 1 2 >>

Object#define_singleton_method(symbol, method) -> Symbol (50.0)

self に特異メソッド name を定義します。

...

@
param symbol メソッド名を String または Symbol で指定します。

@
param method Proc、Method あるいは UnboundMethod の
いずれかのインスタンスを指定します。

@
return メソッド名を表す Symbol を返します。

//emlist[][ruby]{
class
A...
...class << self
def class_name
to_s
end
end
end
A.define_singleton_method(:who_am_i) do
"I am: #{class_name}"
end
A.who_am_i # ==> "I am: A"

guy = "Bob"
guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
guy.hello #=> "Bob: Hello there!"
//}...

Object#===(other) -> bool (44.0)

case 式で使用されるメソッドです。d:spec/control#case も参照してください。

...定義すべきです。

デフォルトでは内部で Object#== を呼び出します。

when 節の式をレシーバーとして === を呼び出すことに注意してください。

また Enumerable#grep でも使用されます。

@
param other 比較するオブジェクトです。

//...
...t! #{arg}"
when String
"Instance of String class. But don't hit."
else
"unknown"
end
end

puts check([]) #=> unknown
puts check("mash-up in Ruby on Rails") #=> instance of String class. But not hit...
puts check("<Ruby's world>") #=> hit! <Ruby's world>
//}

@
see Object#==, Range#===,...

Object#public_method(name) -> Method (32.0)

オブジェクトの public メソッド name をオブジェクト化した Method オブジェクトを返します。

...クトの public メソッド name をオブジェクト化した
Method オブジェクトを返します。

@
param name メソッド名を Symbol または String で指定します。
@
raise NameError 定義されていないメソッド名や、
protected メソッド名、 private メ...
...ソッド名を引数として与えると発生します。

//emlist[][ruby]{
1.public_method(:to_int) #=> #<Method: Integer#to_int>
1.public_method(:p) # method `p' for class `Integer' is private (NameError)
//}

@
see Object#method,Object#public_send,Module#public_instance_method...
<< < 1 2 >>