class AsciiParadise::Sparky::CLI

Public Class Methods

run(*i) click to toggle source
#

AsciiParadise::Sparky::CLI.run

Helper method to run an instance with the given arguments.

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

#
# File lib/ascii_paradise/sparky/cli.rb, line 21
def self.run(*i)
  instance = new
  instance.run(*i)
  instance
end

Public Instance Methods

help() click to toggle source
#

help

Returns usage information for the sparkyc omponent.

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

EXAMPLES:
  sparky 1 5 22 13 53
  ▁▁▃▂▇

  sparky 0,30,55,80,33,150
  ▁▂▃▅▂▇

  echo 9 13 5 17 1 | sparky
  ▄▆▂█▁

    "
  end
run(*i) click to toggle source
#

run

Runs sparky with the given input argument.

The method will return nil.

#
# File lib/ascii_paradise/sparky/cli.rb, line 34
def run(*i)
  if i.empty? || (i.size == 1 && %w(-h --help).include?(i.first))
    puts help
  else
    sparkline = Sparky.new(i.map(&:to_f))
    puts sparkline.to_s
  end
end