78件ヒット
[1-78件を表示]
(0.037秒)
別のキーワード
種類
- インスタンスメソッド (36)
- クラス (24)
- 文書 (18)
ライブラリ
- delegate (24)
- forwardable (24)
- weakref (12)
モジュール
- Forwardable (24)
- Kernel (12)
キーワード
- DelegateClass (12)
-
NEWS for Ruby 2
. 7 . 0 (6) - Ruby用語集 (12)
- SimpleDelegator (12)
- WeakRef (12)
-
instance
_ delegate (12)
検索結果
先頭5件
-
Forwardable
# delegate(hash) -> () (18120.0) -
メソッドの委譲先を設定します。
...定します。キーは Symbol、
String かその配列で指定します。
例:
require 'forwardable'
class Zap
extend Forwardable
delegate :length => :@str
delegate [:first, :last] => :@arr
def initialize
@arr = %w/foo bar baz/
@str = "worl... -
Kernel
# DelegateClass(superclass) -> object (14112.0) -
クラス superclass のインスタンスへメソッドを委譲するクラスを定義し、 そのクラスを返します。
...るクラスを定義し、
そのクラスを返します。
@param superclass 委譲先となるクラス
例:
//emlist{
require 'delegate'
class ExtArray < DelegateClass(Array)
def initialize
super([])
end
end
a = ExtArray.new
p a.class # => ExtArray
a.push 25
p a # => [25]... -
SimpleDelegator (8012.0)
-
Delegator クラスを継承し、シンプルなメソッド委譲を実現した具象クラス。
...し、シンプルなメソッド委譲を実現した具象クラス。
委譲先に指定されたオブジェクトへメソッドの実行を委譲します。
例:
//emlist{
require 'delegate'
foo = Object.new
def foo.test
p 25
end
foo2 = SimpleDelegator.new(foo)
foo2.test # => 25
//}... -
Forwardable
# instance _ delegate(hash) -> () (6120.0) -
メソッドの委譲先を設定します。
...定します。キーは Symbol、
String かその配列で指定します。
例:
require 'forwardable'
class Zap
extend Forwardable
delegate :length => :@str
delegate [:first, :last] => :@arr
def initialize
@arr = %w/foo bar baz/
@str = "worl... -
Ruby用語集 (24.0)
-
Ruby用語集 A B C D E F G I J M N O R S Y
...ッシュに呼び出しを丸投げすることで実装が簡素化できる。
標準添付ライブラリーには、委譲を支援する delegate や
forwardable がある。
: イテレーター
: iterator
一般には繰り返し(反復)を抽象化する仕組み全般を指す......まれているクラス。
ライブラリーを require することなく使うことができる。
参照:_builtin
: 組み込みライブラリー
: built-in library
Ruby 本体に組み込まれているライブラリー。require せずに使うことができる。
: クラス
:......る。
Ruby 2.7 以降では case/in の As パターンでも使う。
参照:d:spec/literal#hash
: ロードパス
スクリプトを require、load などで読み込む(ロードする)とき、
ファイルの位置を絶対パスで与えなくても、ファイル名(拡張... -
NEWS for Ruby 2
. 7 . 0 (18.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...以前のlazyではないEnumerator#with_indexのデフォルト実装から
lazyになりました。7877
//emlist[Enumerator.produce][ruby]{
require "date"
dates = Enumerator.produce(Date.today, &:succ) #=> infinite sequence of dates
dates.detect(&:tuesday?) #=> next Tuesday
//}
//emlist[Enume......* Date.jisx0301, Date#jisx0301, Date.parseが新しい日本の年号を
サポートしました。 15742
* Delegator
* Object#DelegateClassがブロックを受け付けるようになり、
Class.newやStruct.newのように返り値のクラスのコンテキストで......ionParser
* 不明なオプションに対して "Did you mean?" が表示されるようになりました。 16256
//emlist[test.rb][ruby]{
require "optparse"
OptionParser.new do |opts|
opts.on("-f", "--foo", "foo") {|v| }
opts.on("-b", "--bar", "bar") {|v| }
opts.on("-c", "--baz", "baz... -
WeakRef (12.0)
-
weak reference を実現するクラスです。
...あります。
アクセスしようとしたときにオブジェクトが GC されていれば
WeakRef::RefError が発生します。
delegate も参照してください。
=== サンプルコード
require 'weakref'
foo = Object.new
ref = WeakRef.new(foo)
ref.some_method_of_foo...