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.
7 8 9 10 11 12 13 |
# File 'lib/contentstack/entry_collection.rb', line 7 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.
5 6 7 |
# File 'lib/contentstack/entry_collection.rb', line 5 def content_type @content_type end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
5 6 7 |
# File 'lib/contentstack/entry_collection.rb', line 5 def count @count end |
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
5 6 7 |
# File 'lib/contentstack/entry_collection.rb', line 5 def entries @entries end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
5 6 7 |
# File 'lib/contentstack/entry_collection.rb', line 5 def schema @schema end |
Instance Method Details
#collect(&block) ⇒ Object
23 24 25 |
# File 'lib/contentstack/entry_collection.rb', line 23 def collect &block self.each(&block) end |
#each(&block) ⇒ Object
15 16 17 |
# File 'lib/contentstack/entry_collection.rb', line 15 def each &block @entries.map{|e| block.call(e)} end |
#first ⇒ Object
31 32 33 |
# File 'lib/contentstack/entry_collection.rb', line 31 def first @entries.first end |
#get(index) ⇒ Object
39 40 41 |
# File 'lib/contentstack/entry_collection.rb', line 39 def get(index) @entries[index] end |
#last ⇒ Object
35 36 37 |
# File 'lib/contentstack/entry_collection.rb', line 35 def last @entries.last end |
#length ⇒ Object
27 28 29 |
# File 'lib/contentstack/entry_collection.rb', line 27 def length @entries.length end |
#map(&block) ⇒ Object
19 20 21 |
# File 'lib/contentstack/entry_collection.rb', line 19 def map &block self.each(&block) end |