Class: Codewars::TrainNext

Inherits:
Thor
  • Object
show all
Defined in:
lib/codewars/train_next.rb

Instance Method Summary collapse

Constructor Details

#initializeTrainNext



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/codewars/train_next.rb', line 3

def initialize
  message = []
  api_key = Configuration.option('api_key')
  message.push 'You should set an api-key to use this command' unless api_key
  language = Configuration.option('language')
  message.push 'You should set an default language to use this command' unless language
  fail Thor::Error, message.join("\n") unless message.empty?

  client = CodewarsApi::Client.new(api_key: api_key)
  kata = client.train_next_kata(
    language: language.split(',').first,
    peek: 'true',
    strategy: 'default'
  )
  handle_next_kata(kata)
end