Sha256: e1b4b3b3098d7901992947fe5c9482acf04fc15ee0d99b764dce1b67b3d961a7
Contents?: true
Size: 964 Bytes
Versions: 4
Compression:
Stored size: 964 Bytes
Contents
module MikePlayer class Display PAUSE_INDICATOR = '||'.freeze INDICATOR_SIZE = 4 def initialize @width = 0 @indicator = '' @changed = false end def song_info=(v) @info_prefix = "\r#{v}".freeze end def elapsed=(v) @indicator = "#{'>' * (v % INDICATOR_SIZE)}".ljust(INDICATOR_SIZE) @changed = true end def paused if (false == @indicator.include?(PAUSE_INDICATOR)) @indicator = PAUSE_INDICATOR.ljust(INDICATOR_SIZE) @changed = true end end def display!(elapsed_info, countdown = nil) return unless changed? mindicator = "(#{countdown}↓) " if countdown print("\r" << ' '.ljust(@width)) info = "#{@info_prefix} #{elapsed_info} #{mindicator}#{@indicator}" print(info) @width = info.size @changed = false $stdout.flush end def changed? true == @changed end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
mikeplayer-1.1.1 | lib/mikeplayer/display.rb |
mikeplayer-1.1.0 | lib/mikeplayer/display.rb |
mikeplayer-1.0.8 | lib/mikeplayer/display.rb |
mikeplayer-1.0.7 | lib/mikeplayer/display.rb |