Class: Leetcoder::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/leetcoder/leetcoder/collection.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/leetcoder/leetcoder/collection.rb', line 5

def data
  @data
end

Class Method Details

.from_response(response, key:, type: Object) ⇒ Object



7
8
9
10
# File 'lib/leetcoder/leetcoder/collection.rb', line 7

def self.from_response(response, key:, type: Object)
  response.dig(*key).map { |attrs| type.new(attrs) }
  # response.dig(*key[0...-1], 'total')
end