Module: Contentful::ArrayLike
- Includes:
- Enumerable
- Defined in:
- lib/contentful/array_like.rb
Overview
Useful methods for array-like resources that can be included if an :items property exists
Instance Method Summary collapse
-
#[](*args) ⇒ 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.
-
#to_ary ⇒ Contentful::Entry, Contentful::Asset
Delegates to items#to_ary.
Instance Method Details
#[](*args) ⇒ Contentful::Entry, Contentful::Asset
Delegates to items#[]
42 43 44 |
# File 'lib/contentful/array_like.rb', line 42 def [](*args) items[*args] end |
#array? ⇒ true
Returns true for array-like resources
12 13 14 |
# File 'lib/contentful/array_like.rb', line 12 def array? true end |
#each_item {|Contentful::Entry, Contentful::Asset| ... } ⇒ Object Also known as: each
Delegates to items#each
19 20 21 |
# File 'lib/contentful/array_like.rb', line 19 def each_item(&block) items.each(&block) end |
#empty? ⇒ Boolean
Delegates to items#empty?
27 28 29 |
# File 'lib/contentful/array_like.rb', line 27 def empty? items.empty? end |
#last ⇒ Contentful::Entry, Contentful::Asset
Delegates to items#last
49 50 51 |
# File 'lib/contentful/array_like.rb', line 49 def last items.last end |
#size ⇒ Number Also known as: length
Delegetes to items#size
34 35 36 |
# File 'lib/contentful/array_like.rb', line 34 def size items.size end |
#to_ary ⇒ Contentful::Entry, Contentful::Asset
Delegates to items#to_ary
56 57 58 |
# File 'lib/contentful/array_like.rb', line 56 def to_ary items end |