Class: Sparkr::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/sparkr/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(*args) ⇒ CLI

Helper method to run an instance with the given args

Returns:

  • (CLI)

    the instance that ran

See Also:



9
10
11
12
13
# File 'lib/sparkr/cli.rb', line 9

def self.run(*args)
  instance = new
  instance.run(*args)
  instance
end

Instance Method Details

#run(*args) ⇒ void

This method returns an undefined value.

Runs sparkr with the given args



17
18
19
20
21
22
23
24
# File 'lib/sparkr/cli.rb', line 17

def run(*args)
  if args.empty? || (args.size == 1 && %w(-h --help).include?(args.first))
    puts help
  else
    sparkline = Sparkline.new(args.map(&:to_f))
    puts sparkline.to_s
  end
end