Class: Contentstack::EntryCollection
- Inherits:
-
Object
- Object
- Contentstack::EntryCollection
- Defined in:
- lib/contentstack/entry_collection.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
- #collect(&block) ⇒ Object
- #each(&block) ⇒ Object
- #first ⇒ Object
- #get(index) ⇒ Object
-
#initialize(json, content_type_uid = nil) ⇒ EntryCollection
constructor
A new instance of EntryCollection.
- #last ⇒ Object
- #length ⇒ Object
- #map(&block) ⇒ Object
Constructor Details
#initialize(json, content_type_uid = nil) ⇒ EntryCollection
Returns a new instance of EntryCollection.
9 10 11 12 13 14 15 |
# File 'lib/contentstack/entry_collection.rb', line 9 def initialize(json, content_type_uid=nil) @count = json["count"] if json["count"] @entries = json["entries"].collect{|entry| Entry.new(entry, content_type_uid) } @schema = json["schema"].symbolize_keys if json["schema"] @content_type = json["content_type"].symbolize_keys if json["content_type"] self end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
7 8 9 |
# File 'lib/contentstack/entry_collection.rb', line 7 def content_type @content_type end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
7 8 9 |
# File 'lib/contentstack/entry_collection.rb', line 7 def count @count end |
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
7 8 9 |
# File 'lib/contentstack/entry_collection.rb', line 7 def entries @entries end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
7 8 9 |
# File 'lib/contentstack/entry_collection.rb', line 7 def schema @schema end |
Instance Method Details
#collect(&block) ⇒ Object
25 26 27 |
# File 'lib/contentstack/entry_collection.rb', line 25 def collect &block self.each(&block) end |
#each(&block) ⇒ Object
17 18 19 |
# File 'lib/contentstack/entry_collection.rb', line 17 def each &block @entries.map{|e| block.call(e)} end |
#first ⇒ Object
33 34 35 |
# File 'lib/contentstack/entry_collection.rb', line 33 def first @entries.first end |
#get(index) ⇒ Object
41 42 43 |
# File 'lib/contentstack/entry_collection.rb', line 41 def get(index) @entries[index] end |
#last ⇒ Object
37 38 39 |
# File 'lib/contentstack/entry_collection.rb', line 37 def last @entries.last end |
#length ⇒ Object
29 30 31 |
# File 'lib/contentstack/entry_collection.rb', line 29 def length @entries.length end |
#map(&block) ⇒ Object
21 22 23 |
# File 'lib/contentstack/entry_collection.rb', line 21 def map &block self.each(&block) end |