INNER CODE UNIT · Ruby

self

busyloop/lolcat · lib/lolcat/lol.rb:43

  def self.cat(fd, opts={})
    @os = opts[:os]
    print "\e[?25l" if opts[:animate]
    while true do
      buf = ''
      begin
        begin
          buf += fd.sysread(4096)
          invalid_encoding = !buf.dup.force_encoding(fd.external_encoding).valid_encoding?
        end while invalid_encoding or buf.match(INCOMPLETE_ESCAPE)
      rescue EOFError
        break
      end
      buf.force_encoding(fd.external_encoding)
      buf.lines.each do |line|
        @os += 1
        println(line, opts)
      end

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…