Module: InstanceStorage
- Defined in:
- lib/instance_storage.rb,
lib/instance_storage/version.rb
Overview
クラスに、インスタンスの辞書をもたせる。このモジュールをincludeすると、全てのインスタンスは一意な名前(Symbol)をもつようになり、その名前を通してインスタンスを取得することができるようになる。
Defined Under Namespace
Modules: InstanceStorageExtend
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Attribute Summary collapse
-
#name ⇒ Object
(also: #to_sym)
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(name) ⇒ Object
-
#to_s ⇒ Object
名前を文字列にして返す ==== Return 名前文字列.
Instance Attribute Details
#name ⇒ Object (readonly) Also known as: to_sym
Returns the value of attribute name.
9 10 11 |
# File 'lib/instance_storage.rb', line 9 def name @name end |
Class Method Details
.included(klass) ⇒ Object
13 14 15 16 |
# File 'lib/instance_storage.rb', line 13 def self.included(klass) klass.extend InstanceStorageExtend klass.clear! end |
Instance Method Details
#initialize(name) ⇒ Object
18 19 |
# File 'lib/instance_storage.rb', line 18 def initialize(name) @name = name end |
#to_s ⇒ Object
名前を文字列にして返す
Return
名前文字列
24 25 |
# File 'lib/instance_storage.rb', line 24 def to_s @name.to_s end |