lib/ayadn/scroll.rb in ayadn-1.2.1 vs lib/ayadn/scroll.rb in ayadn-1.2.2

- old
+ new

@@ -3,10 +3,11 @@ class Scroll def initialize(api, view) @api = api @view = view + @chars = %w{ | / - \\ } end def method_missing(meth, options, niceranks = {}) case meth.to_s when 'trending', 'photos', 'checkins', 'replies', 'global', 'unified' @@ -33,11 +34,11 @@ end target = "explore:#{target}" if explore?(target) show_if_new(stream, options, target, niceranks) target = orig_target if target =~ /explore/ options = save_then_return(stream, options) - pause + countdown rescue Interrupt canceled end end end @@ -49,11 +50,11 @@ loop do begin stream = @api.get_mentions(username, options) show_if_new(stream, options, "mentions:#{id}") options = save_then_return(stream, options) - pause + countdown rescue Interrupt canceled end end end @@ -65,11 +66,11 @@ loop do begin stream = @api.get_posts(username, options) show_if_new(stream, options, "posts:#{id}") options = save_then_return(stream, options) - pause + countdown rescue Interrupt canceled end end end @@ -79,11 +80,11 @@ loop do begin stream = @api.get_convo(post_id, options) show_if_new(stream, options, "replies:#{post_id}") options = save_then_return(stream, options) - pause + countdown rescue Interrupt canceled end end end @@ -93,19 +94,40 @@ loop do begin stream = @api.get_messages(channel_id, options) show_if_new(stream, options, "channel:#{channel_id}") options = save_then_return(stream, options) - pause + countdown rescue Interrupt canceled end end end private + def countdown + if Settings.options[:timeline][:show_spinner] == true + waiting + else + pause + end + end + + def clear + print("\r") + print(" ".ljust(5)) + print("\r") + end + + def spin + print(@chars[0]) # Print the next character... + sleep(0.1) # ...wait 100ms... + print("\b") # ...move the cursor back by one... + @chars.push(@chars.shift) # ...rotate the characters array. + end + def get(target, options) case target when 'global' @api.get_global(options) when 'unified' @@ -125,9 +147,16 @@ case target when 'trending', 'photos', 'checkins', 'replies' true else false + end + end + + def waiting + interval = Settings.options[:scroll][:timer] * 10 + interval.times do + spin end end def pause sleep Settings.options[:scroll][:timer]