Sha256: 28b4ef23bd12fdcd693e20cf468be6ec02537c2cf69013573c50c53ebf315dd3

Contents?: true

Size: 712 Bytes

Versions: 1

Compression:

Stored size: 712 Bytes

Contents

require "net/http"

define_command :startrek, doc: "Play a Star Trek animation file" do
  buffer = Buffer.find_or_new("*summary*", undo_limit: 0,
                              read_only: true)
  switch_to_buffer(buffer)
  buffer.read_only_edit do
    buffer.replace("")
  end
  message("Loading...")
  background do
    s = Net::HTTP.get(URI("http://artscene.textfiles.com/vt100/startrek.vt"))
    frames = s.sub(/\A\e\[H\e\[J\n/, "").split(/\e\[H\n/)
    foreground do
      message("")
    end
    frames.each do |frame|
      foreground do
        buffer.read_only_edit do
          buffer.replace(frame)
        end
      end
      sleep(0.1)
    end
    foreground do
      message("END")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
textbringer-startrek-1.0.0 lib/textbringer/startrek.rb