Class: Theseus::CLI
- Inherits:
-
Object
- Object
- Theseus::CLI
- Defined in:
- lib/theseus/cli.rb
Constant Summary collapse
- TYPE_MAP =
{ "ortho" => Theseus::OrthogonalMaze, "delta" => Theseus::DeltaMaze, "sigma" => Theseus::SigmaMaze, "upsilon" => Theseus::UpsilonMaze, }
- ALGO_MAP =
{ "backtrack" => Theseus::Algorithms::RecursiveBacktracker, "kruskal" => Theseus::Algorithms::Kruskal, "prim" => Theseus::Algorithms::Prim, }
Instance Attribute Summary collapse
-
#animate ⇒ Object
Returns the value of attribute animate.
-
#delay ⇒ Object
Returns the value of attribute delay.
-
#format ⇒ Object
Returns the value of attribute format.
-
#maze_opts ⇒ Object
readonly
Returns the value of attribute maze_opts.
-
#output ⇒ Object
Returns the value of attribute output.
-
#png_opts ⇒ Object
readonly
Returns the value of attribute png_opts.
-
#solution ⇒ Object
Returns the value of attribute solution.
-
#sparse ⇒ Object
Returns the value of attribute sparse.
-
#type ⇒ Object
Returns the value of attribute type.
-
#unicursal ⇒ Object
Returns the value of attribute unicursal.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(*args) ⇒ CLI
Returns a new instance of CLI.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/theseus/cli.rb', line 40 def initialize(*args) args.flatten! @animate = false @delay = 50 @output = "maze" @sparse = 0 @unicursal = false @type = "ortho" @format = :ascii @solution = nil @png_opts = Theseus::Formatters::PNG::DEFAULTS.dup @maze_opts = { mask: nil, width: nil, height: nil, randomness: 50, weave: 0, symmetry: :none, braid: 0, wrap: :none, entrance: nil, exit: nil, algorithm: ALGO_MAP["backtrack"] } option_parser.parse!(args) if args.any? abort "extra arguments detected: #{args.inspect}" end normalize_settings! end |
Instance Attribute Details
#animate ⇒ Object
Returns the value of attribute animate.
28 29 30 |
# File 'lib/theseus/cli.rb', line 28 def animate @animate end |
#delay ⇒ Object
Returns the value of attribute delay.
29 30 31 |
# File 'lib/theseus/cli.rb', line 29 def delay @delay end |
#format ⇒ Object
Returns the value of attribute format.
34 35 36 |
# File 'lib/theseus/cli.rb', line 34 def format @format end |
#maze_opts ⇒ Object (readonly)
Returns the value of attribute maze_opts.
37 38 39 |
# File 'lib/theseus/cli.rb', line 37 def maze_opts @maze_opts end |
#output ⇒ Object
Returns the value of attribute output.
30 31 32 |
# File 'lib/theseus/cli.rb', line 30 def output @output end |
#png_opts ⇒ Object (readonly)
Returns the value of attribute png_opts.
38 39 40 |
# File 'lib/theseus/cli.rb', line 38 def png_opts @png_opts end |
#solution ⇒ Object
Returns the value of attribute solution.
35 36 37 |
# File 'lib/theseus/cli.rb', line 35 def solution @solution end |
#sparse ⇒ Object
Returns the value of attribute sparse.
31 32 33 |
# File 'lib/theseus/cli.rb', line 31 def sparse @sparse end |
#type ⇒ Object
Returns the value of attribute type.
33 34 35 |
# File 'lib/theseus/cli.rb', line 33 def type @type end |
#unicursal ⇒ Object
Returns the value of attribute unicursal.
32 33 34 |
# File 'lib/theseus/cli.rb', line 32 def unicursal @unicursal end |
Class Method Details
.run(*args) ⇒ Object
24 25 26 |
# File 'lib/theseus/cli.rb', line 24 def self.run(*args) new(*args).run end |
Instance Method Details
#run ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/theseus/cli.rb', line 66 def run if @animate run_animation else run_static end end |