Class: Pennylane::ListObject

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/pennylane/list_object.rb

Instance Attribute Summary

Attributes inherited from Object

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

descendants, #initialize_from_response, objects, protected_fields

Class Method Details

.build_from(response, params = {}, opts = {}) ⇒ Object



9
10
11
# File 'lib/pennylane/list_object.rb', line 9

def self.build_from(response, params = {}, opts = {})
  new.initialize_from_response(response)
end

.object_nameObject



5
6
7
# File 'lib/pennylane/list_object.rb', line 5

def self.object_name
  'list'
end

Instance Method Details

#dataObject



17
18
19
# File 'lib/pennylane/list_object.rb', line 17

def data
  @values[key_for(@values)]
end

#each(&blk) ⇒ Object



13
14
15
# File 'lib/pennylane/list_object.rb', line 13

def each(&blk)
  data.each(&blk)
end

#key_for(resp) ⇒ Object



21
22
23
# File 'lib/pennylane/list_object.rb', line 21

def key_for(resp)
  resp.keys.find { |k| Pennylane::ObjectTypes.object_names_to_classes.keys.include?(Util.singularize(k.to_s)) } || resp.keys.find { |k| resp[k].is_a? Array }
end