Class: TTYtest::Capture

Inherits:
Object
  • Object
show all
Includes:
Matchers
Defined in:
lib/ttytest/capture.rb

Constant Summary

Constants included from Matchers

Matchers::METHODS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Matchers

#assert_cursor_hidden, #assert_cursor_position, #assert_cursor_visible, #assert_matches, #assert_row

Constructor Details

#initialize(contents, cursor_x: 0, cursor_y: 0, width: nil, height: nil, cursor_visible: true) ⇒ Capture

Returns a new instance of Capture.



8
9
10
11
12
13
14
15
16
17
# File 'lib/ttytest/capture.rb', line 8

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

Instance Attribute Details

#cursor_xObject (readonly)

Returns the value of attribute cursor_x.



5
6
7
# File 'lib/ttytest/capture.rb', line 5

def cursor_x
  @cursor_x
end

#cursor_yObject (readonly)

Returns the value of attribute cursor_y.



5
6
7
# File 'lib/ttytest/capture.rb', line 5

def cursor_y
  @cursor_y
end

#heightObject (readonly)

Returns the value of attribute height.



6
7
8
# File 'lib/ttytest/capture.rb', line 6

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



6
7
8
# File 'lib/ttytest/capture.rb', line 6

def width
  @width
end

Instance Method Details

#captureObject



35
36
37
# File 'lib/ttytest/capture.rb', line 35

def capture
  self
end

#cursor_hidden?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/ttytest/capture.rb', line 31

def cursor_hidden?
  !cursor_visible?
end

#cursor_visible?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ttytest/capture.rb', line 27

def cursor_visible?
  @cursor_visible
end

#row(row) ⇒ Object



23
24
25
# File 'lib/ttytest/capture.rb', line 23

def row(row)
  rows[row]
end

#rowsObject



19
20
21
# File 'lib/ttytest/capture.rb', line 19

def rows
  @rows
end

#to_sObject



39
40
41
# File 'lib/ttytest/capture.rb', line 39

def to_s
  rows.join("\n")
end