Module: Contentful::ArrayLike

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

#[](*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

Returns:

  • (true)


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?

Returns:

  • (Boolean)


27
28
29
# File 'lib/contentful/array_like.rb', line 27

def empty?
  items.empty?
end

#lastContentful::Entry, Contentful::Asset

Delegates to items#last



49
50
51
# File 'lib/contentful/array_like.rb', line 49

def last
  items.last
end

#sizeNumber Also known as: length

Delegetes to items#size

Returns:

  • (Number)


34
35
36
# File 'lib/contentful/array_like.rb', line 34

def size
  items.size
end

#to_aryContentful::Entry, Contentful::Asset

Delegates to items#to_ary



56
57
58
# File 'lib/contentful/array_like.rb', line 56

def to_ary
  items
end