Sha256: f34664a0d326b60d09fe42e9d1f4e462e271248baed435bc89ab868b05e6121c

Contents?: true

Size: 531 Bytes

Versions: 1

Compression:

Stored size: 531 Bytes

Contents

require 'highline'

module WhirledPeas
  module Device
    class Screen
      def initialize(output: STDOUT)
        @output = output
      end

      def handle_rendered_frames(rendered_frames)
        next_frame_at = Time.now
        rendered_frames.each do |rendered_frame|
          next_frame_at += rendered_frame.duration
          output.print(rendered_frame.strokes)
          output.flush
          sleep([0, next_frame_at - Time.now].max)
        end
      end

      private

      attr_reader :output
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whirled_peas-0.13.0 lib/whirled_peas/device/screen.rb