Class: TTYtest::Capture
- Inherits:
-
Object
- Object
- TTYtest::Capture
- Includes:
- Matchers
- Defined in:
- lib/ttytest/capture.rb
Constant Summary
Constants included from Matchers
Instance Attribute Summary collapse
-
#cursor_visible ⇒ Object
readonly
Returns the value of attribute cursor_visible.
-
#cursor_x ⇒ Object
readonly
Returns the value of attribute cursor_x.
-
#cursor_y ⇒ Object
readonly
Returns the value of attribute cursor_y.
Instance Method Summary collapse
- #capture ⇒ Object
- #cursor_position ⇒ Object
-
#initialize(contents, cursor_x: 0, cursor_y: 0, cursor_visible: true) ⇒ Capture
constructor
A new instance of Capture.
- #row(row) ⇒ Object
- #rows ⇒ Object
- #to_s ⇒ Object
Methods included from Matchers
#assert_cursor_position, #assert_row
Constructor Details
#initialize(contents, cursor_x: 0, cursor_y: 0, cursor_visible: true) ⇒ Capture
Returns a new instance of Capture.
7 8 9 10 11 12 13 14 |
# File 'lib/ttytest/capture.rb', line 7 def initialize(contents, cursor_x: 0, cursor_y: 0, cursor_visible: true) @rows = (contents+"\nEND").split("\n")[0...-1].map do |row| row || "" end @cursor_x = cursor_x @cursor_y = cursor_y @cursor_visible = cursor_visible end |
Instance Attribute Details
#cursor_visible ⇒ Object (readonly)
Returns the value of attribute cursor_visible.
5 6 7 |
# File 'lib/ttytest/capture.rb', line 5 def cursor_visible @cursor_visible end |
#cursor_x ⇒ Object (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_y ⇒ Object (readonly)
Returns the value of attribute cursor_y.
5 6 7 |
# File 'lib/ttytest/capture.rb', line 5 def cursor_y @cursor_y end |
Instance Method Details
#capture ⇒ Object
28 29 30 |
# File 'lib/ttytest/capture.rb', line 28 def capture self end |
#cursor_position ⇒ Object
16 17 18 |
# File 'lib/ttytest/capture.rb', line 16 def cursor_position [@cursor_x, @cursor_y] end |
#row(row) ⇒ Object
24 25 26 |
# File 'lib/ttytest/capture.rb', line 24 def row(row) rows[row] end |
#rows ⇒ Object
20 21 22 |
# File 'lib/ttytest/capture.rb', line 20 def rows @rows end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/ttytest/capture.rb', line 32 def to_s rows.join("\n") end |