Class: Retell::SDK::Unofficial::BaseList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/retell/sdk/unofficial/base_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items_key, raw_response) ⇒ BaseList

Returns a new instance of BaseList.



9
10
11
# File 'lib/retell/sdk/unofficial/base_list.rb', line 9

def initialize(items_key, raw_response)
  @items = raw_response[items_key]
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



7
8
9
# File 'lib/retell/sdk/unofficial/base_list.rb', line 7

def items
  @items
end

Instance Method Details

#[](index) ⇒ Object



13
14
15
# File 'lib/retell/sdk/unofficial/base_list.rb', line 13

def [](index)
  @items[index]
end

#eachObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/retell/sdk/unofficial/base_list.rb', line 17

def each
  if block_given?
    to_a.each do |value|
      yield(value)
    end
    to_a
  else
    to_enum(:each)
  end
end

#empty?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/retell/sdk/unofficial/base_list.rb', line 38

def empty?
  @items.empty?
end

#firstObject



42
43
44
# File 'lib/retell/sdk/unofficial/base_list.rb', line 42

def first
  @items.first
end

#lastObject



46
47
48
# File 'lib/retell/sdk/unofficial/base_list.rb', line 46

def last
  @items.last
end

#lengthObject Also known as: size



28
29
30
# File 'lib/retell/sdk/unofficial/base_list.rb', line 28

def length
  @items.length
end

#to_aObject



34
35
36
# File 'lib/retell/sdk/unofficial/base_list.rb', line 34

def to_a
  @items
end