Sha256: c398d5be7bdb3e84709ec3d388d6394a71ac1b555276770da1ed687ee89695c0

Contents?: true

Size: 773 Bytes

Versions: 1

Compression:

Stored size: 773 Bytes

Contents

# encoding: utf-8

module Sparkr
  class CLI
    # Helper method to run an instance with the given +args+
    #
    # @see #run
    # @return [CLI] the instance that ran
    def self.run(*args)
      instance = new
      instance.run(*args)
      instance
    end

    # Runs sparkr with the given +args+
    # @return [void]
    def run(*args)
      if args.empty?
        puts help
      else
        sparkline = Sparkline.new(args.map(&:to_f))
        puts sparkline.to_s
      end
    end

    private

    # Returns usage information
    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sparkr-0.4.0 lib/sparkr/cli.rb