Class: Katagen::Strategy::LeetCode
- Inherits:
-
Object
- Object
- Katagen::Strategy::LeetCode
- Defined in:
- lib/katagen/strategy/leetcode.rb
Overview
Generator for leetcode questions
Instance Method Summary collapse
- #build_question_info ⇒ Object
-
#initialize(id) ⇒ LeetCode
constructor
A new instance of LeetCode.
Constructor Details
#initialize(id) ⇒ LeetCode
Returns a new instance of LeetCode.
19 20 21 22 |
# File 'lib/katagen/strategy/leetcode.rb', line 19 def initialize(id) @id = id.to_i raise InvalidIndex.new(@id) unless @id.positive? end |
Instance Method Details
#build_question_info ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/katagen/strategy/leetcode.rb', line 24 def build_question_info summary = questions_summary.find { |q| q["id"] == @id } raise QuestionNotExist.new(@id) unless summary topic, difficulty = summary.values_at("topic", "difficulty") QuestionInfo.new( "#{difficulty}/#{@id}.#{topic}", "https:/leetcode.com/problems/#{topic}" ) end |