Sha256: 3f1117ffe52ba57ca7b3a31002bd7b792aa5aa39e1eac95987d9eb02c7b262b3
Contents?: true
Size: 553 Bytes
Versions: 6
Compression:
Stored size: 553 Bytes
Contents
require 'highline' module WhirledPeas module Device class Screen def initialize(refresh_rate, output: STDOUT) @refresh_rate = refresh_rate @output = output end def handle_renders(renders) renders.each do |strokes| frame_at = Time.now output.print(strokes) output.flush next_frame_at = frame_at + 1.0 / refresh_rate sleep([0, next_frame_at - Time.now].max) end end private attr_reader :refresh_rate, :output end end end
Version data entries
6 entries across 6 versions & 1 rubygems