Class: Glossarist::Collections::Collection
- Inherits:
-
Object
- Object
- Glossarist::Collections::Collection
- Includes:
- Enumerable
- Defined in:
- lib/glossarist/collections/collection.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
Instance Method Summary collapse
- #<<(object) ⇒ Object
- #clear! ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(klass:) ⇒ Collection
constructor
A new instance of Collection.
Constructor Details
#initialize(klass:) ⇒ Collection
Returns a new instance of Collection.
12 13 14 15 |
# File 'lib/glossarist/collections/collection.rb', line 12 def initialize(klass:) @klass = klass @collection = [] end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
8 9 10 |
# File 'lib/glossarist/collections/collection.rb', line 8 def collection @collection end |
Instance Method Details
#<<(object) ⇒ Object
17 18 19 |
# File 'lib/glossarist/collections/collection.rb', line 17 def <<(object) @collection << @klass.new(object) end |
#clear! ⇒ Object
29 30 31 |
# File 'lib/glossarist/collections/collection.rb', line 29 def clear! @collection = [] end |
#each(&block) ⇒ Object
21 22 23 |
# File 'lib/glossarist/collections/collection.rb', line 21 def each(&block) @collection.each(&block) end |
#empty? ⇒ Boolean
25 26 27 |
# File 'lib/glossarist/collections/collection.rb', line 25 def empty? @collection.empty? end |