This commit is contained in:
Aşkın Gedik 2015-12-30 16:21:42 +02:00
parent 39b3f8680c
commit b31b23d45f
6 changed files with 41 additions and 39 deletions

View file

@ -30,7 +30,7 @@ sp.stop
`delay`: `default = 0.1` `delay`: `default = 0.1`
`chars`: you can choose charset from [CHARSET](src/spinner/charset.cr) `default = CHARSET[:pipe]` `chars`: you can choose charset from [CHARSET](src/spinner/charset.cr) `default = Spinner::Charset[:pipe]`
## Examples ## Examples
@ -38,7 +38,7 @@ sp.stop
require "spinner" require "spinner"
require "colorize" require "colorize"
chars = CHARSET[:arrow].map do |c| chars = Spinner::Charset[:arrow].map do |c|
c.colorize(:light_green) c.colorize(:light_green)
end end

View file

@ -1,6 +1,6 @@
require "../src/spinner" require "../src/spinner"
CHARSET.values.each do |chars| Spinner::Charset.values.each do |chars|
sp = Spin.new(0.1, chars) sp = Spin.new(0.1, chars)
sp.start sp.start
sleep 2 sleep 2

View file

@ -1,7 +1,7 @@
require "../src/spinner" require "../src/spinner"
require "colorize" require "colorize"
chars = CHARSET[:arrow].map do |c| chars = Spinner::Charset[:arrow].map do |c|
c.colorize(:light_green) c.colorize(:light_green)
end end

View file

@ -7,13 +7,13 @@ sleep 3
sp.stop sp.stop
puts "end!" puts "end!"
sp1 = Spin.new(0.1, CHARSET[:three_dots]) sp1 = Spin.new(0.1, Spinner::Charset[:three_dots])
sp1.start sp1.start
sleep 3 sleep 3
sp1.stop sp1.stop
sp1 = Spin.new(0.1) sp1 = Spin.new(0.1)
sp1.chars = CHARSET[:arrow] sp1.chars = Spinner::Charset[:arrow]
sp1.start sp1.start
sleep 3 sleep 3
sp1.stop sp1.stop

View file

@ -6,7 +6,7 @@ class Spin
CL = STDOUT.tty? ? "\u001b[0G" : "\u000d \u000d" CL = STDOUT.tty? ? "\u001b[0G" : "\u000d \u000d"
CLEAR = STDOUT.tty? ? "\u001b[2K" : "\u000d" CLEAR = STDOUT.tty? ? "\u001b[2K" : "\u000d"
def initialize(@delay = 0.1, @chars = CHARSET[:pipe]) def initialize(@delay = 0.1, @chars = Spinner::Charset[:pipe])
@state = true @state = true
end end

View file

@ -1,4 +1,5 @@
CHARSET = { module Spinner
Charset = {
arrow: {"", "", "", "", "", "", "", ""}, arrow: {"", "", "", "", "", "", "", ""},
fan: {"", "", "", "", "", "", "", ""}, fan: {"", "", "", "", "", "", "", ""},
fan1: {"+", "x"}, fan1: {"+", "x"},
@ -30,3 +31,4 @@ CHARSET = {
progress3: {"[ ]", "[=> ]", "[===> ]", "[=====> ]", "[======> ]", "[========> ]", "[==========> ]", "[============> ]", "[==============> ]", "[================> ]", "[==================> ]", "[===================>]"}, progress3: {"[ ]", "[=> ]", "[===> ]", "[=====> ]", "[======> ]", "[========> ]", "[==========> ]", "[============> ]", "[==============> ]", "[================> ]", "[==================> ]", "[===================>]"},
fish: {">))'> ", " >))'> ", " >))'> ", " >))'> ", " >))'>", " <'((<", " <'((< ", " <'((< ", " <'((< ", "<'((< "}, fish: {">))'> ", " >))'> ", " >))'> ", " >))'> ", " >))'>", " <'((<", " <'((< ", " <'((< ", " <'((< ", "<'((< "},
} }
end