Class: CodewarsCli::SubmitKata
- Inherits:
-
Object
- Object
- CodewarsCli::SubmitKata
- Includes:
- FileParserHelpers, GenericHelpers
- Defined in:
- lib/codewars_cli/submit_kata.rb
Instance Attribute Summary collapse
-
#kata_name ⇒ Object
readonly
Returns the value of attribute kata_name.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(kata_name, language) ⇒ SubmitKata
constructor
A new instance of SubmitKata.
- #upload_kata ⇒ Object
Methods included from FileParserHelpers
#_fetch_info, #_kata_path, #_parse_description_file
Methods included from GenericHelpers
#check_for_api_key, #client, #error, #extend_object, included, #info, #presenter
Constructor Details
#initialize(kata_name, language) ⇒ SubmitKata
Returns a new instance of SubmitKata.
17 18 19 20 |
# File 'lib/codewars_cli/submit_kata.rb', line 17 def initialize(kata_name, language) @kata_name = kata_name @language = language || Configuration.language end |
Instance Attribute Details
#kata_name ⇒ Object (readonly)
Returns the value of attribute kata_name.
15 16 17 |
# File 'lib/codewars_cli/submit_kata.rb', line 15 def kata_name @kata_name end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
15 16 17 |
# File 'lib/codewars_cli/submit_kata.rb', line 15 def language @language end |
Class Method Details
.find(kata_name, language) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/codewars_cli/submit_kata.rb', line 5 def self.find(kata_name, language) check_for_api_key if kata_name new(kata_name, language) else error("ERROR: You must provide the name of the kata") exit(1) end end |
Instance Method Details
#upload_kata ⇒ Object
22 23 24 25 26 |
# File 'lib/codewars_cli/submit_kata.rb', line 22 def upload_kata code = _get_kata_solution_code(kata_name, language) response = client.attemp_solution(kata: _parse_description_file(kata_name, language), code: code) Deferred.new(kata_name, language, response, client) end |