class Sparkr::CLI

Public Class Methods

run(*args) click to toggle source

Helper method to run an instance with the given args

@see run @return [CLI] the instance that ran

# File lib/sparkr/cli.rb, line 9
def self.run(*args)
  instance = new
  instance.run(*args)
  instance
end

Public Instance Methods

run(*args) click to toggle source

Runs sparkr with the given args @return [void]

# 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

Private Instance Methods

help() click to toggle source

Returns usage information

# File lib/sparkr/cli.rb, line 29
    def help
      """
USAGE:
  sparkr [-h|--help] VALUE,...

EXAMPLES:
  sparkr 1 5 22 13 53
  ▁▁▃▂█
  sparkr 0,30,55,80,33,150
  ▁▂▃▄▂█
  echo 9 13 5 17 1 | sparkr
  ▄▆▂█▁
      """
    end