class Codewars::Description

Constants

DESCRIPTION_FILE_NAME

Public Instance Methods

print_kata_desc(kata) click to toggle source
take_value_from_file(regex_with_group, param_key) click to toggle source
# File lib/codewars/description.rb, line 6
def take_value_from_file(regex_with_group, param_key)
  @data ||= read_file(DESCRIPTION_FILE_NAME)
  param = @data.match(regex_with_group)
  unless param
    raise Thor::Error, "'#{param_key}' has not been found in the 'description.md' file."
  end
  param[1]
end

Private Instance Methods

print_parameter(parameter, value, value_color = nil, value_bold = false) click to toggle source
read_file(file_name) click to toggle source
# File lib/codewars/description.rb, line 29
def read_file(file_name)
  desc_path = File.expand_path(file_name)
  unless File.exist? desc_path
    raise Thor::Error, "The file '#{file_name}' has not been found in the current directory."
  end
  File.read(desc_path)
end