Sha256: 811881abb50869d3b19895e3673aa838197badf6ec355a21065e8c8913884a34
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 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 one the console" option :discs, type: :numeric, default: 3 option :constrained, type: :boolean def console towers = Towers.new options[:discs] if options[:constrained] towers = ConstrainedTowers.new options[:discs] end towers.each do |state| puts state end puts "%d moves to solve for %d discs" % [towers.total, options[:discs]] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hanoi-jane-0.1.2 | lib/hanoi/jane/cli.rb |
hanoi-jane-0.1.1 | lib/hanoi/jane/cli.rb |