Class: Vedeu::Repositories::Collection Private
- Inherits:
-
Object
- Object
- Vedeu::Repositories::Collection
- Includes:
- Common, Assemblage
- Defined in:
- lib/vedeu/repositories/collection.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Convert an Array into an object which has some meaning in the context it is being used. Various classes throughout Vedeu subclass this class.
Direct Known Subclasses
Events::Events, Input::Keys, Views::Chars, Views::Lines, Views::Streams, Views::Views
Instance Attribute Summary collapse
- #collection ⇒ Array|Vedeu::Repositories::Collection (also: #all, #value) readonly private
- #name ⇒ String|Symbol|NilClass
- #parent ⇒ Fixnum
Class Method Summary collapse
Instance Method Summary collapse
-
#add(other) ⇒ Vedeu::Repositories::Collection
(also: #<<)
private
Adds an entry to the collection.
-
#initialize(collection = [], parent = nil, name = nil) ⇒ Vedeu::Repositories::Collection
constructor
private
Returns a new instance of Vedeu::Repositories::Collection.
-
#klass ⇒ void
private
private
Return the inheriting class.
-
#to_s ⇒ String
(also: #to_str)
private
Returns the collection as a String.
Methods included from Assemblage
#[], #any?, #each, #empty?, #eql?, #size
Methods included from Common
#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?
Constructor Details
#initialize(collection = [], parent = nil, name = nil) ⇒ Vedeu::Repositories::Collection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Vedeu::Repositories::Collection.
52 53 54 55 56 |
# File 'lib/vedeu/repositories/collection.rb', line 52 def initialize(collection = [], parent = nil, name = nil) @collection = collection @parent = parent @name = name end |
Instance Attribute Details
#collection ⇒ Array|Vedeu::Repositories::Collection (readonly) Also known as: all, value
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/vedeu/repositories/collection.rb', line 20 def collection @collection end |
#name ⇒ String|Symbol|NilClass
30 31 32 |
# File 'lib/vedeu/repositories/collection.rb', line 30 def name @name end |
#parent ⇒ Fixnum
26 27 28 |
# File 'lib/vedeu/repositories/collection.rb', line 26 def parent @parent end |
Class Method Details
.coerce(collection = [], parent = nil, name = nil) ⇒ Vedeu::Repositories::Collection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 39 40 41 42 43 44 |
# File 'lib/vedeu/repositories/collection.rb', line 36 def self.coerce(collection = [], parent = nil, name = nil) if collection.is_a?(Vedeu::Repositories::Collection) collection else new(Array(collection), parent, name) end end |
Instance Method Details
#add(other) ⇒ Vedeu::Repositories::Collection Also known as: <<
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds an entry to the collection.
62 63 64 65 66 67 68 69 70 |
# File 'lib/vedeu/repositories/collection.rb', line 62 def add(other) if other.is_a?(Vedeu::Repositories::Collection) return klass.coerce(other, parent, name) if empty? else klass.new(@collection += Array(other), parent, name) end end |
#klass ⇒ void (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Return the inheriting class.
86 87 88 |
# File 'lib/vedeu/repositories/collection.rb', line 86 def klass self.class end |
#to_s ⇒ String Also known as: to_str
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the collection as a String.
76 77 78 |
# File 'lib/vedeu/repositories/collection.rb', line 76 def to_s collection.map(&:to_s).join end |