別のキーワード
ライブラリ
- ビルトイン (337)
- forwardable (24)
- observer (12)
- ostruct (12)
- singleton (12)
クラス
- BasicObject (12)
- Data (6)
- Module (156)
- NoMethodError (40)
- Object (36)
- OpenStruct (12)
- Regexp (48)
モジュール
- Forwardable (24)
- Observable (12)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - Data (3)
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 3 . 0 (10) -
NEWS for Ruby 2
. 6 . 0 (7) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 1 . 0 (4) - Range (12)
- Rational (12)
- Singleton (12)
-
add
_ observer (12) - args (12)
-
def
_ delegator (12) -
def
_ instance _ delegator (12) - define (6)
-
did
_ you _ mean (12) -
initialize
_ copy (12) -
last
_ match (24) - match (24)
-
method
_ missing (12) -
module
_ function (36) - new (31)
- private (48)
-
private
_ call? (9) - public (48)
-
public
_ class _ method (24) -
public
_ send (24) -
ruby 1
. 8 . 3 feature (12) -
ruby 1
. 8 . 4 feature (12)
検索結果
先頭5件
-
Object
# initialize _ copy(obj) -> object (12.0) -
(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。
...c9d4>
# tainted?: false
# singleton methods: #<NoMethodError: ...>
check obj.dup
#=> instance variables: #<Object:0x4019c9c0 @foo=1>
# tainted?: true
# singleton methods: #<NoMethodError: ...>
check obj.clone
#=> instance variables: #<Object:0x......#=> instance variables: #<Object:0x4019c9d4>
# singleton methods: #<NoMethodError: ...>
check obj.dup
#=> instance variables: #<Object:0x4019c9c0 @foo=1>
# singleton methods: #<NoMethodError: ...>
check obj.clone
#=> instance variables: #<Object:0x4019c880 @foo=... -
Object
# public _ send(name , *args) -> object (12.0) -
オブジェクトの public メソッド name を args を引数にして呼び出し、メソッ ドの実行結果を返します。
...しなかった場合に発生します。
@raise NoMethodError protected メソッドや private メソッドに対して実行
した場合に発生します。
//emlist[][ruby]{
1.public_send(:puts, "hello") # => NoMethodError
//}
@see BasicObject#__send__, Object#send... -
Object
# public _ send(name , *args) { . . . . } -> object (12.0) -
オブジェクトの public メソッド name を args を引数にして呼び出し、メソッ ドの実行結果を返します。
...しなかった場合に発生します。
@raise NoMethodError protected メソッドや private メソッドに対して実行
した場合に発生します。
//emlist[][ruby]{
1.public_send(:puts, "hello") # => NoMethodError
//}
@see BasicObject#__send__, Object#send... -
Observable
# add _ observer(observer , func=:update) -> Array (12.0) -
オブザーバを登録します。
...きは
例外 NoMethodError が発生します。
func を指定することで update 以外のメソッドを通知に用いることができます。
@param observer 更新の通知を受けるオブザーバ
@param func 更新の通知をするメソッド
@raise NoMethodError updateメソッ... -
Regexp
# match(str , pos = 0) -> MatchData | nil (12.0) -
指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。
...s では、マッチに失敗した場合、
nil.captures を呼び出そうとして例外 NoMethodError が発生して
しまいます。
//emlist[例][ruby]{
foo, bar, baz = /(foo)(bar)(baz)/.match("foobar").captures
# => -:1: undefined method `captures' for nil:NilClass (NoMethodError)
//}......に失敗した場合、
nil.captures を呼び出そうとして例外 NoMethodError が発生して
しまいます。
//emlist[例][ruby]{
foo, bar, baz = /(foo)(bar)(baz)/.match("foobar").captures
# => -:1: undefined method `captures' for nil:NilClass (NoMethodError)
//}
@see Regexp#match?... -
Regexp
# match(str , pos = 0) {|m| . . . } -> object | nil (12.0) -
指定された文字列 str に対して位置 pos から自身が表す正規表現によるマッ チングを行います。マッチした場合には結果を MatchData オブジェクトで返し ます。 マッチしなかった場合 nil を返します。
...s では、マッチに失敗した場合、
nil.captures を呼び出そうとして例外 NoMethodError が発生して
しまいます。
//emlist[例][ruby]{
foo, bar, baz = /(foo)(bar)(baz)/.match("foobar").captures
# => -:1: undefined method `captures' for nil:NilClass (NoMethodError)
//}......に失敗した場合、
nil.captures を呼び出そうとして例外 NoMethodError が発生して
しまいます。
//emlist[例][ruby]{
foo, bar, baz = /(foo)(bar)(baz)/.match("foobar").captures
# => -:1: undefined method `captures' for nil:NilClass (NoMethodError)
//}
@see Regexp#match?... -
BasicObject
# method _ missing(name , *args) -> object (6.0) -
呼びだされたメソッドが定義されていなかった時、Rubyインタプリタがこのメソッド を呼び出します。
...の名前 (Symbol) が name に
その時の引数が第二引数以降に渡されます。
デフォルトではこのメソッドは例外 NoMethodError を発生させます。
@param name 未定義メソッドの名前(シンボル)です。
@param args 未定義メソッドに渡され... -
Data (6.0)
-
「値オブジェクト(value object)」の定義に利用できるクラスです。
...fred.name # => "Fred"
# キーワード引数でも構築できる
p Dog.new(name: "Terry", age: 3)
# メンバの値を書き換えることはできない
fred.age = 6 # => NoMethodError
//}
なお、Ruby 2.7 以前に存在し Ruby 3.0 で削除された Data クラスとは異なります。... -
Data
. define(*args) -> Class (6.0) -
Data クラスに新しいサブクラスを作って、それを返します。
...を書き換えることはできません。
//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
fred.age = 6 # => NoMethodError
//}
メンバを持たないサブクラスも定義可能です。
以下のように、パターンマッチに利用できます。
//emli... -
Data
. define(*args) {|subclass| block } -> Class (6.0) -
Data クラスに新しいサブクラスを作って、それを返します。
...を書き換えることはできません。
//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
fred.age = 6 # => NoMethodError
//}
メンバを持たないサブクラスも定義可能です。
以下のように、パターンマッチに利用できます。
//emli... -
Forwardable
# def _ delegator(accessor , method , ali = method) -> () (6.0) -
メソッドの委譲先を設定します。
...emlist[例][ruby]{
require 'forwardable'
class MyQueue
extend Forwardable
attr_reader :queue
def initialize
@queue = []
end
def_delegator :@queue, :push, :mypush
end
q = MyQueue.new
q.mypush 42
q.queue # => [42]
q.push 23 # => NoMethodError
//}
@see Forwardable#def_delegators...
