class Riffer::Rig::Terminal::Loading
Constants
- FRAMES
- QUIPS
- QUIP_TICKS
- TICK_SECONDS
Public Class Methods
(frame: Riffer::Rig::Terminal::Frame, random: Random) → void
Source
# File lib/riffer/rig/terminal/loading.rb, line 30 def initialize(frame:, random:) @frame = frame @random = random @halt = Queue.new @thread = nil @tick = 0 @quip = '' end
@rbs frame: Riffer::Rig::Terminal::Frame @rbs random: Random @rbs return: void
Public Instance Methods
() → void
Source
# File lib/riffer/rig/terminal/loading.rb, line 40 def start tick @thread = Thread.new { tick until @halt.pop(timeout: TICK_SECONDS) } end
@rbs return: void
() → void
Source
# File lib/riffer/rig/terminal/loading.rb, line 46 def stop @halt << true @thread&.join end
@rbs return: void
() → void
Source
# File lib/riffer/rig/terminal/loading.rb, line 52 def tick # The banner, an error, or the frame stopping ends the loading row; the # halt handed to this thread's own wait below ends it without another lap. unless @frame.loading? @halt << true return end roll if (@tick % QUIP_TICKS).zero? @frame.loading("#{FRAMES.fetch(@tick % FRAMES.size)} #{@quip}") @tick += 1 end
@rbs return: void