class Codewars::TrainNext

Public Class Methods

new(client) click to toggle source
# File lib/codewars/train_next.rb, line 3
def initialize(client)
  language = Configuration.option('language')
  raise Thor::Error, 'You should set an default language to use this command' unless language

  kata = client.train_next_kata(
    language: language,
    peek: 'true',
    strategy: 'default'
  )
  handle_next_kata(kata)
end

Private Instance Methods

handle_next_kata(kata) click to toggle source
# File lib/codewars/train_next.rb, line 17
def handle_next_kata(kata)
  if !kata.success && (kata.reason.eql? 'unauthorized')
    raise Thor::Error, 'Wrong api key'
  end
  Description.new.print_kata_desc(kata)
end