Sha256: 1a3d2ec824e082b5567fde418de1d18ea6405d18419ca089ecbcd108db35f3d8

Contents?: true

Size: 461 Bytes

Versions: 1

Compression:

Stored size: 461 Bytes

Contents

require 'jared/buffer_line'

module JarEd
  class Buffer
    def initialize(filename)
      @file = File.open(filename, "r")
    end

    def lines
      @lines ||= file.each_line.to_a.map { |line| BufferLine.new(line) }
    end

    def wrapped_lines(width:, height:, offset:)
      lines.
        slice(offset, lines.length - 1).
        flat_map { |line| line.wrap(width: width) }.
        first(height)
    end

    private

    attr_reader :file
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jareditor-3.0.0 lib/jared/buffer.rb