Class: Memit::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/memit/cli.rb

Instance Method Summary collapse

Instance Method Details

#askmeObject



6
7
8
9
10
11
12
13
14
15
16
17
# 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) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# 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

#whichdataObject



33
34
35
36
37
# File 'lib/memit/cli.rb', line 33

def whichdata
  c = config_repository.load

  puts c.data_path
end