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`
`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
@ -38,7 +38,7 @@ sp.stop
require "spinner"
require "colorize"
chars = CHARSET[:arrow].map do |c|
chars = Spinner::Charset[:arrow].map do |c|
c.colorize(:light_green)
end

View file

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

View file

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

View file

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

View file

@ -6,7 +6,7 @@ class Spin
CL = STDOUT.tty? ? "\u001b[0G" : "\u000d \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
end

View file

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