Module: Contentful::ArrayLike

Includes:
Enumerable
Included in:
Array, SyncPage
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

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

Returns:

  • (true)


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?

Returns:

  • (Boolean)


25
26
27
# File 'lib/contentful/array_like.rb', line 25

def empty?
  items.empty?
end

#lastContentful::Entry, Contentful::Asset

Delegates to items#last



47
48
49
# File 'lib/contentful/array_like.rb', line 47

def last
  items.last
end

#sizeNumber Also known as: length

Delegetes to items#size

Returns:

  • (Number)


32
33
34
# File 'lib/contentful/array_like.rb', line 32

def size
  items.size
end