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.
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.
-
#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.
51 52 53 54 55 |
# File 'lib/vedeu/repositories/collection.rb', line 51 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.
19 20 21 |
# File 'lib/vedeu/repositories/collection.rb', line 19 def collection @collection end |
#name ⇒ String|Symbol|NilClass
29 30 31 |
# File 'lib/vedeu/repositories/collection.rb', line 29 def name @name end |
#parent ⇒ Fixnum
25 26 27 |
# File 'lib/vedeu/repositories/collection.rb', line 25 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.
35 36 37 38 39 40 41 42 43 |
# File 'lib/vedeu/repositories/collection.rb', line 35 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.
61 62 63 64 65 66 67 68 69 |
# File 'lib/vedeu/repositories/collection.rb', line 61 def add(other) if other.is_a?(Vedeu::Repositories::Collection) return self.class.coerce(other, parent, name) if empty? else self.class.new(@collection += Array(other), parent, name) end 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.
75 76 77 |
# File 'lib/vedeu/repositories/collection.rb', line 75 def to_s collection.map(&:to_s).join end |