Module: Contentful::ArrayLike
Overview
Useful methods for array-like resources that can be included if an :items property exists
Instance Method Summary collapse
-
#[](index) ⇒ Contentful::Entry, Contentful::Asset
Delegates to items#[].
-
#array? ⇒ true
Returns true for array-like resources.
-
#each_item {|Contentful::Entry, Contentful::Asset| ... } ⇒ Object
(also: #each)
Delegates to items#each.
-
#empty? ⇒ Boolean
Delegates to items#empty?.
-
#last ⇒ Contentful::Entry, Contentful::Asset
Delegates to items#last.
-
#size ⇒ Number
(also: #length)
Delegetes to items#size.
Instance Method Details
#[](index) ⇒ Contentful::Entry, Contentful::Asset
Delegates to items#[]
40 41 42 |
# File 'lib/contentful/array_like.rb', line 40 def [](index) items[index] end |
#array? ⇒ true
Returns true for array-like resources
10 11 12 |
# File 'lib/contentful/array_like.rb', line 10 def array? true end |
#each_item {|Contentful::Entry, Contentful::Asset| ... } ⇒ Object Also known as: each
Delegates to items#each
17 18 19 |
# File 'lib/contentful/array_like.rb', line 17 def each_item(&block) items.each(&block) end |
#empty? ⇒ Boolean
Delegates to items#empty?
25 26 27 |
# File 'lib/contentful/array_like.rb', line 25 def empty? items.empty? end |
#last ⇒ Contentful::Entry, Contentful::Asset
Delegates to items#last
47 48 49 |
# File 'lib/contentful/array_like.rb', line 47 def last items.last end |
#size ⇒ Number Also known as: length
Delegetes to items#size
32 33 34 |
# File 'lib/contentful/array_like.rb', line 32 def size items.size end |