Class: Zold::Calculate

Inherits:
Object
  • Object
show all
Includes:
ThreadBadge
Defined in:
lib/zold/commands/calculate.rb

Overview

Calculate score

Instance Method Summary collapse

Constructor Details

#initialize(log: Loog::NULL) ⇒ Calculate

Returns a new instance of Calculate.



20
21
22
# File 'lib/zold/commands/calculate.rb', line 20

def initialize(log: Loog::NULL)
  @log = log
end

Instance Method Details

#run(args = []) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/zold/commands/calculate.rb', line 24

def run(args = [])
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
    o.banner = "Usage: zold score [options]
Available options:"
    o.string '--time',
      'The time to start a score prefix with (default: current time)',
      default: Time.now.utc.iso8601
    o.string '--invoice',
      'The invoice you want to collect money to'
    o.integer '--port',
      "TCP port to open for the Net (default: #{Remotes::PORT})",
      default: Remotes::PORT
    o.string '--host', 'Host name (default: 127.0.0.1)',
      default: '127.0.0.1'
    o.integer '--strength',
      "The strength of the score (default: #{Score::STRENGTH})",
      default: Score::STRENGTH
    o.integer '--max',
      'Maximum value to find and then stop (default: 8)',
      default: 8
    o.bool '--hide-hash', 'Don\'t print hash',
      default: false
    o.bool '--hide-time', 'Don\'t print calculation time per each score',
      default: false
    o.bool '--help', 'Print instructions'
  end
  if opts.help?
    @log.info(opts.to_s)
    return
  end
  calculate(opts)
end