Class: Keisanjaku::App

Inherits:
Object
  • Object
show all
Defined in:
lib/keisanjaku/app.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv, input: $stdin, output: $stdout, error: $stderr) ⇒ App

Returns a new instance of App.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/keisanjaku/app.rb', line 15

def initialize(argv, input: $stdin, output: $stdout, error: $stderr)
  @argv = argv.dup
  @input = input
  @output = output
  @error = error
  @options = {
    color: ENV["NO_COLOR"].nil?,
    animate: true,
    width: nil,
    tolerance: 1.0,
    slide: 0.0,
    cursor: 0.0,
    face: :front
  }
end

Instance Method Details

#runObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/keisanjaku/app.rb', line 31

def run
  parse_options
  return print_version if @options[:version]
  return render_only if @options[:render_only]
  return key_test if @options[:key_test]
  return run_demo(@options[:demo]) if @options[:demo]
  return run_drill if @options[:drill]
  return run_sandbox if @options[:sandbox]

  expression = @argv.join(" ").strip
  return run_demo(expression) unless expression.empty?

  run_menu
rescue ParseError, ScaleError, OptionParser::ParseError => e
  @error.puts "keisanjaku: #{e.message}"
  1
end