Class: AsciiParadise::Sparky::CLI
- Inherits:
-
Object
- Object
- AsciiParadise::Sparky::CLI
- Defined in:
- lib/ascii_paradise/sparky/cli.rb
Class Method Summary collapse
-
.run(*i) ⇒ CLI
# === AsciiParadise::Sparky::CLI.run.
Instance Method Summary collapse
-
#help ⇒ Object
# === help.
-
#run(*i) ⇒ Object
# === run.
Class Method Details
.run(*i) ⇒ CLI
#
AsciiParadise::Sparky::CLI.run
Helper method to run an instance with the given arguments.
#
21 22 23 24 25 |
# File 'lib/ascii_paradise/sparky/cli.rb', line 21 def self.run(*i) instance = new instance.run(*i) instance end |
Instance Method Details
#help ⇒ Object
#
help
Returns usage information for the sparkyc omponent.
#
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# 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) ⇒ Object
#
run
Runs sparky with the given input argument.
The method will return nil.
#
34 35 36 37 38 39 40 41 |
# 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 |