Skip to content

Commit

Permalink
Change to extract character genertion.
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed Jul 13, 2016
1 parent 87b204c commit b2198fd
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions lib/tty/spinner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,7 @@ def stop(stop_message = '')
end
return clear_line if @clear

char = if success?
@success_mark
elsif error?
@error_mark
else
@frames[@current - 1]
end
data = message.gsub(MATCHER, char)

data = message.gsub(MATCHER, next_char)
if !stop_message.empty?
data << ' ' + stop_message
end
Expand All @@ -234,6 +226,21 @@ def stop(stop_message = '')
kill
end

# Retrieve next character
#
# @return [String]
#
# @api private
def next_char
if success?
@success_mark
elsif error?
@error_mark
else
@frames[@current - 1]
end
end

# Finish spinning and set state to :success
#
# @api public
Expand Down

0 comments on commit b2198fd

Please sign in to comment.