Class: Githug::CLI

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

Instance Method Summary collapse

Instance Method Details

#hintObject



29
30
31
32
33
# File 'lib/githug/cli.rb', line 29

def hint
  if level = load_level
    level.show_hint
  end
end

#levelsObject



59
60
61
62
63
64
# File 'lib/githug/cli.rb', line 59

def levels
  list_with_numbers = Level.list.each_with_index.map do |name, index|
    "##{index + 1}: #{name}"
  end
  UI.puts(list_with_numbers)
end

#playObject



11
12
13
14
15
# File 'lib/githug/cli.rb', line 11

def play
  UI.word_box("Githug")
  make_directory!
  Game.new.play_level
end

#reset(path = nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/githug/cli.rb', line 45

def reset(path = nil)
  level = load_level(path)
  UI.word_box("Githug")
  if level
    UI.puts("resetting level")
    level.setup_level
    level.full_description
  else
    UI.error("Level does not exist")
  end
end

#test(path) ⇒ Object



20
21
22
23
24
25
# File 'lib/githug/cli.rb', line 20

def test(path)
  UI.word_box("Githug")
  make_directory!
  level = Level.load_from_file(path)
  Game.new.test_level(level, options[:errors])
end