Class: CodewarsApi::TrainNextKata

Inherits:
Object
  • Object
show all
Defined in:
lib/codewars_api/train_next_kata.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ TrainNextKata

Returns a new instance of TrainNextKata


3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/codewars_api/train_next_kata.rb', line 3

def initialize(options)
  api_key = options.delete!(:api_key)
  language = options.delete!(:language)

  request_options = {}
  request_options = RequestHelper.add_api_key(request_options, api_key)
  request_options = RequestHelper.add_body_options(request_options, options)

  @response = RequestHelper.post(
    "#{CodewarsApi::API_URL}/code-challenges/#{language}/train",
    request_options
  )
end

Instance Method Details

#authorObject


37
38
39
# File 'lib/codewars_api/train_next_kata.rb', line 37

def author
  @response.to_h['author']
end

#average_completionObject


45
46
47
# File 'lib/codewars_api/train_next_kata.rb', line 45

def average_completion
  @response.to_h['averageCompletion']
end

#codeObject


69
70
71
# File 'lib/codewars_api/train_next_kata.rb', line 69

def code
  @response.to_h['session'].andand['code']
end

#code_setupObject


61
62
63
# File 'lib/codewars_api/train_next_kata.rb', line 61

def code_setup
  @response.to_h['session'].andand['setup']
end

#descriptionObject


33
34
35
# File 'lib/codewars_api/train_next_kata.rb', line 33

def description
  @response.to_h['description']
end

#hrefObject


29
30
31
# File 'lib/codewars_api/train_next_kata.rb', line 29

def href
  @response.to_h['href']
end

#nameObject


21
22
23
# File 'lib/codewars_api/train_next_kata.rb', line 21

def name
  @response.to_h['name']
end

#project_idObject


53
54
55
# File 'lib/codewars_api/train_next_kata.rb', line 53

def project_id
  @response.to_h['session'].andand['projectId']
end

#rankObject


41
42
43
# File 'lib/codewars_api/train_next_kata.rb', line 41

def rank
  @response.to_h['rank']
end

#slugObject


25
26
27
# File 'lib/codewars_api/train_next_kata.rb', line 25

def slug
  @response.to_h['slug']
end

#solution_idObject


57
58
59
# File 'lib/codewars_api/train_next_kata.rb', line 57

def solution_id
  @response.to_h['session'].andand['solutionId']
end

#successObject


17
18
19
# File 'lib/codewars_api/train_next_kata.rb', line 17

def success
  @response.to_h['success']
end

#tagsObject


49
50
51
# File 'lib/codewars_api/train_next_kata.rb', line 49

def tags
  @response.to_h['tags']
end

#tests_setupObject


65
66
67
# File 'lib/codewars_api/train_next_kata.rb', line 65

def tests_setup
  @response.to_h['session'].andand['exampleFixture']
end

#to_hObject


73
74
75
# File 'lib/codewars_api/train_next_kata.rb', line 73

def to_h
  @response.to_h
end