Class: Codewars::TrainSpecific

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

Instance Method Summary collapse

Constructor Details

#initialize(id_or_slug) ⇒ TrainSpecific

Returns a new instance of TrainSpecific.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/codewars/train_specific.rb', line 5

def initialize(id_or_slug)
  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?

  say "Starting the '#{id_or_slug}' kata."

  client = CodewarsApi::Client.new(api_key: api_key)
  kata = client.train_specific_kata(
    language: language,
    id_or_slug: id_or_slug
  )
  handle_specific_kata(kata, language)
end