Class: Leetcoder::QuestionsResource
- Inherits:
-
BaseResource
- Object
- BaseResource
- Leetcoder::QuestionsResource
- Defined in:
- lib/leetcoder/leetcoder/resources/questions.rb
Instance Attribute Summary
Attributes inherited from BaseResource
Instance Method Summary collapse
-
#accepted_list ⇒ Object
returns the list of only accepted leetcode problems.
-
#list ⇒ Object
# returns the list of all leetcode problems, not usued.
-
#retrieve(title_slug) ⇒ Object
returns a single problem data.
Methods inherited from BaseResource
#cache_response, #get_request, #gql_request, #initialize, #post_request
Methods included from Helpers::GqlQueries
#default_limit, #problemset_query, #question_data_query, #submissions_query
Constructor Details
This class inherits a constructor from Leetcoder::BaseResource
Instance Method Details
#accepted_list ⇒ Object
returns the list of only accepted leetcode problems
6 7 8 9 10 |
# File 'lib/leetcoder/leetcoder/resources/questions.rb', line 6 def accepted_list response = gql_request(query: problemset_query, variables: { filters: { status: 'AC' } }) Collection.from_response(response.body, key: %i[data problemsetQuestionList questions]) end |
#list ⇒ Object
# returns the list of all leetcode problems, not usued
13 14 15 16 17 18 |
# File 'lib/leetcoder/leetcoder/resources/questions.rb', line 13 def list request = proc { gql_request(query: problemset_query, variables: { filters: {} }) } response = cache_response('questions_cache.yml', request, update: false) Collection.from_response(response.body, key: %i[data problemsetQuestionList questions]) end |
#retrieve(title_slug) ⇒ Object
returns a single problem data
21 22 23 24 25 |
# File 'lib/leetcoder/leetcoder/resources/questions.rb', line 21 def retrieve(title_slug) response = gql_request(query: question_data_query(title_slug:)) Object.from_response(response.body, key: %i[data question]) end |