class WhirledPeas::Device::Screen

Attributes

output[R]

Public Class Methods

new(output: STDOUT) click to toggle source
# File lib/whirled_peas/device/screen.rb, line 6
def initialize(output: STDOUT)
  @output = output
end

Public Instance Methods

handle_rendered_frames(rendered_frames) click to toggle source
# File lib/whirled_peas/device/screen.rb, line 10
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