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

cursor_x[R]
cursor_y[R]
height[R]
width[R]

Public Class Methods

new(contents, cursor_x: 0, cursor_y: 0, width: nil, height: nil, cursor_visible: true) click to toggle source

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

capture() click to toggle source

@return [Capture] returns self

# File lib/ttytest/capture.rb, line 48
def capture
  self
end
cursor_hidden?() click to toggle source

@return [true,false] Whether the cursor is hidden in the captured terminal

# File lib/ttytest/capture.rb, line 43
def cursor_hidden?
  !cursor_visible?
end
cursor_visible?() click to toggle source

@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
row(row_number) click to toggle source

@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
rows() click to toggle source

@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
to_s() click to toggle source

@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