class Memit::CLI

Public Instance Methods

askme() click to toggle source
# File lib/memit/cli.rb, line 6
def askme
  c = config_repository.load
  qp = Memit::QuestionProvider.new(c.data_path)
  q, a = qp.random_question

  puts q
  if STDIN.gets.chomp == a
    puts 'Correct!'
  else
    puts "Wrong! Should be '#{a}'."
  end
end
setdata(path) click to toggle source
# File lib/memit/cli.rb, line 20
def setdata(path)
  unless File.exist?(path)
    puts 'Data file does not exist.'
    return
  end

  c = config_repository.load

  c.data_path = path
  config_repository.save(c)
end
whichdata() click to toggle source
# File lib/memit/cli.rb, line 33
def whichdata
  c = config_repository.load

  puts c.data_path
end

Private Instance Methods

config_repository() click to toggle source
# File lib/memit/cli.rb, line 41
def config_repository
  @config_repository ||= Memit::ConfigRepository.new(Memit.config_path)
end