class Snapshot
Public Class Methods
build(data)
click to toggle source
# File lib/asciinema/snapshot.rb, line 6 def self.build(data) data = data.map { |cells| cells.map { |cell| Cell.new(cell[0], Brush.new(cell[1])) } } new(data) end
Public Instance Methods
thumbnail(w, h)
click to toggle source
# File lib/asciinema/snapshot.rb, line 16 def thumbnail(w, h) x = 0 y = height - h - trailing_empty_lines y = 0 if y < 0 crop(x, y, w, h) end
Private Instance Methods
line_empty?(y)
click to toggle source
# File lib/asciinema/snapshot.rb, line 37 def line_empty?(y) lines[y].empty? || lines[y].all? { |cell| cell.empty? } end
trailing_empty_lines()
click to toggle source
# File lib/asciinema/snapshot.rb, line 26 def trailing_empty_lines n = 0 (height - 1).downto(0) do |y| break unless line_empty?(y) n += 1 end n end