module Contentful::ArrayLike
Useful methods for array-like resources that can be included if an :items property exists
Public Instance Methods
[](*args)
click to toggle source
Delegates to items#[]
@return [Contentful::Entry, Contentful::Asset
]
# File lib/contentful/array_like.rb, line 42 def [](*args) items[*args] end
array?()
click to toggle source
Returns true for array-like resources
@return [true]
# File lib/contentful/array_like.rb, line 12 def array? true end
each_item(&block)
click to toggle source
Delegates to items#each
@yield [Contentful::Entry, Contentful::Asset
]
# File lib/contentful/array_like.rb, line 19 def each_item(&block) items.each(&block) end
Also aliased as: each
empty?()
click to toggle source
Delegates to items#empty?
@return [Boolean]
# File lib/contentful/array_like.rb, line 27 def empty? items.empty? end
last()
click to toggle source
Delegates to items#last
@return [Contentful::Entry, Contentful::Asset
]
# File lib/contentful/array_like.rb, line 49 def last items.last end
size()
click to toggle source
Delegetes to items#size
@return [Number]
# File lib/contentful/array_like.rb, line 34 def size items.size end
Also aliased as: length
to_ary()
click to toggle source
Delegates to items#to_ary
@return [Contentful::Entry, Contentful::Asset
]
# File lib/contentful/array_like.rb, line 56 def to_ary items end