Class: HappySystem::AxoCommand

Inherits:
DevSystem::SimpleCommand show all
Defined in:
lib/happy_system/sub/axo/commands/axo_command.rb

Instance Attribute Summary

Attributes inherited from DevSystem::BaseCommand

#env

Instance Method Summary collapse

Methods inherited from DevSystem::SimpleCommand

#call, #log_simple_remember, #simple_arg, #simple_arg_ask, #simple_arg_ask_snakecase, #simple_args, #simple_boolean, #simple_boolean_no, #simple_boolean_yes, #simple_color, #simple_controller_placement, #simple_string

Methods inherited from DevSystem::BaseCommand

call, #call, get_command_signatures

Methods inherited from DevSystem::Command

call, #call, get_command_signatures

Methods inherited from Liza::Controller

color, inherited, on_connected

Methods inherited from Liza::Unit

const_missing, division, part, system, #system, test_class

Instance Method Details

#call_defaultObject



5
6
7
8
9
10
11
12
# File 'lib/happy_system/sub/axo/commands/axo_command.rb', line 5

def call_default
  find!

  env[:axo] = @axo
  HappyBox[:axo].call(env)

  log "done at #{Time.now}"
end

#find!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/happy_system/sub/axo/commands/axo_command.rb', line 14

def find!
  @name = simple_args[0]

  if @name
    @axo = Liza.const "#{@name}_axo"
    return
  end

  @axo = pick_axo
  @name = @axo.last_namespace.snakecase
ensure
  log :high, "@name = #{@name}"
  log :high, "@axo = #{@axo}"
end

#pick_axoObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/happy_system/sub/axo/commands/axo_command.rb', line 29

def pick_axo
  axos = Axo.descendants
  options = axos.sort_by(&:last_namespace).map do |axo|
    [
      "#{axo.last_namespace.snakecase.ljust 30} - #{axo} - #{(axo.get :description) || "No description."}",
      axo
    ]
  end.to_h
  TtyInputCommand.pick_one "Pick an Axolotl ASCII Animation to run", options
end