Class: Githug::CLI

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

Instance Method Summary collapse

Instance Method Details

#hintObject



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

def hint
  if level = load_level
    level.show_hint
  end
end

#levelsObject



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

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



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

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

#reset(path = nil) ⇒ Object



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

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



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

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