class TTYtest::Capture
Represents the complete state of a {TTYtest::Terminal} at the time it was captured (contents, cursor position, etc). @attr_reader [Integer] width the number of columns in the captured terminal @attr_reader [Integer] height the number of rows in the captured terminal @attr_reader [Integer] cursor_x
the cursor's column (starting at 0) in the captured terminal @attr_reader [Integer] cursor_y
the cursor's row (starting at 0) in the captured terminal
Attributes
Public Class Methods
Used internally by drivers when called by {Terminal#capture} @api private
# File lib/ttytest/capture.rb, line 15 def initialize(contents, cursor_x: 0, cursor_y: 0, width: nil, height: nil, cursor_visible: true) @rows = (contents+"\nEND").split("\n")[0...-1].map do |row| row || "" end @cursor_x = cursor_x @cursor_y = cursor_y @width = width @height = height @cursor_visible = cursor_visible end
Public Instance Methods
@return [Capture] returns self
# File lib/ttytest/capture.rb, line 48 def capture self end
@return [true,false] Whether the cursor is visible in the captured terminal
# File lib/ttytest/capture.rb, line 38 def cursor_visible? @cursor_visible end
@param [Integer] the row to return @return [String] the content of the row from the captured terminal
# File lib/ttytest/capture.rb, line 33 def row(row_number) rows[row_number] end
@return [Array<String>] An array of each row's contend from the captured terminal
# File lib/ttytest/capture.rb, line 27 def rows @rows end
@return [String] All rows of the captured terminal, separated by newlines
# File lib/ttytest/capture.rb, line 53 def to_s rows.join("\n") end