Sha256: 059d4c0ebf0bbf6f043318aab00b5bbbbf0d3d993872d0721d108ea7c6583e3b
Contents?: true
Size: 1.41 KB
Versions: 3
Compression:
Stored size: 1.41 KB
Contents
require 'hanoi/jane' module Hanoi module Jane class CLI < ::Thor desc 'version', 'Print hanoi version' def version puts 'hanoi version #{VERSION}' end map %w(-v --version) => :version desc 'phat', "Solve the towers against the pHAT's webserver" option :phat, type: :string, required: true option :constrained, type: :boolean option :interval, type: :numeric, default: 0.3 def phat towers = Towers.new 5 if options[:constrained] towers = ConstrainedTowers.new 5 end towers.each do |state| Hanoi::Jane.hit_phat towers, options[:phat] sleep options[:interval] end end desc 'console', 'Solve the towers on the console' option :discs, type: :numeric, default: 3, minimum: 1 option :constrained, type: :boolean def console if options[:discs] < 1 puts "Solving for %d discs makes no sense" % options[:discs] exit 1 end towers = Towers.new options[:discs] if options[:constrained] towers = ConstrainedTowers.new options[:discs] end towers.each do |state| system('clear') puts state.rebased puts puts state.console sleep 0.2 end puts '%d moves to solve for %d discs' % [towers.total, options[:discs]] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hanoi-jane-0.2.2 | lib/hanoi/jane/cli.rb |
hanoi-jane-0.2.1 | lib/hanoi/jane/cli.rb |
hanoi-jane-0.2.0 | lib/hanoi/jane/cli.rb |