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,32 +1,34 @@
CHARSET = {
arrow: {"", "", "", "", "", "", "", ""},
fan: {"", "", "", "", "", "", "", ""},
fan1: {"+", "x"},
fan2: {"v", "<", "^", ">"},
triangle: {"", "", "", ""},
square: {"", "", "", ""},
circle: {"", "", "", ""},
big_circle: {"", "", "", ""},
boom: {".", "o", "O", "@", "*"},
pipe: {"|", "/", "-", "\\"},
alphabet: {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"},
three_dots: {". ", ".. ", "..."},
eyes: {"◡◡", "⊙⊙", "◠◠"},
dots: {"", "", "", "", "", "", "", ""},
snake: {"", "", "", "", "", "", "", ""},
snake1: {"", "", "", "", "", "", "", "", "", ""},
snake2: {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""},
square1: {"", "", "", ""},
square2: {"", "", "", ""},
square3: {"", "", "", "", "", "", "", "", "", "", "", "", ""},
square4: {"", "", "", "", "", "", "", "", "", "", "", "", ""},
square5: {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""},
thin_arrow: {"", "", "", ""},
big_arraw: {"", "", "", "", "", "", "", ""},
baloon: {".", "o", "O", "°", "O", "o", "."},
progress: {"[ ]", "[= ]", "[== ]", "[=== ]", "[==== ]", "[===== ]", "[====== ]", "[======= ]", "[======== ]", "[========= ]", "[==========]"},
progress1: {"(*---------)", "(-*--------)", "(--*-------)", "(---*------)", "(----*-----)", "(-----*----)", "(------*---)", "(-------*--)", "(--------*-)", "(---------*)"},
progress2: {"█▒▒▒▒▒▒▒▒▒", "███▒▒▒▒▒▒▒", "█████▒▒▒▒▒", "███████▒▒▒", "██████████"},
progress3: {"[ ]", "[=> ]", "[===> ]", "[=====> ]", "[======> ]", "[========> ]", "[==========> ]", "[============> ]", "[==============> ]", "[================> ]", "[==================> ]", "[===================>]"},
fish: {">))'> ", " >))'> ", " >))'> ", " >))'> ", " >))'>", " <'((<", " <'((< ", " <'((< ", " <'((< ", "<'((< "},
}
module Spinner
Charset = {
arrow: {"", "", "", "", "", "", "", ""},
fan: {"", "", "", "", "", "", "", ""},
fan1: {"+", "x"},
fan2: {"v", "<", "^", ">"},
triangle: {"", "", "", ""},
square: {"", "", "", ""},
circle: {"", "", "", ""},
big_circle: {"", "", "", ""},
boom: {".", "o", "O", "@", "*"},
pipe: {"|", "/", "-", "\\"},
alphabet: {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"},
three_dots: {". ", ".. ", "..."},
eyes: {"◡◡", "⊙⊙", "◠◠"},
dots: {"", "", "", "", "", "", "", ""},
snake: {"", "", "", "", "", "", "", ""},
snake1: {"", "", "", "", "", "", "", "", "", ""},
snake2: {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""},
square1: {"", "", "", ""},
square2: {"", "", "", ""},
square3: {"", "", "", "", "", "", "", "", "", "", "", "", ""},
square4: {"", "", "", "", "", "", "", "", "", "", "", "", ""},
square5: {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""},
thin_arrow: {"", "", "", ""},
big_arraw: {"", "", "", "", "", "", "", ""},
baloon: {".", "o", "O", "°", "O", "o", "."},
progress: {"[ ]", "[= ]", "[== ]", "[=== ]", "[==== ]", "[===== ]", "[====== ]", "[======= ]", "[======== ]", "[========= ]", "[==========]"},
progress1: {"(*---------)", "(-*--------)", "(--*-------)", "(---*------)", "(----*-----)", "(-----*----)", "(------*---)", "(-------*--)", "(--------*-)", "(---------*)"},
progress2: {"█▒▒▒▒▒▒▒▒▒", "███▒▒▒▒▒▒▒", "█████▒▒▒▒▒", "███████▒▒▒", "██████████"},
progress3: {"[ ]", "[=> ]", "[===> ]", "[=====> ]", "[======> ]", "[========> ]", "[==========> ]", "[============> ]", "[==============> ]", "[================> ]", "[==================> ]", "[===================>]"},
fish: {">))'> ", " >))'> ", " >))'> ", " >))'> ", " >))'>", " <'((<", " <'((< ", " <'((< ", " <'((< ", "<'((< "},
}
end