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_x ⇒ Object
readonly
Returns the value of attribute cursor_x.
-
#cursor_y ⇒ Object
readonly
Returns the value of attribute cursor_y.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #capture ⇒ Object
- #cursor_hidden? ⇒ Boolean
- #cursor_visible? ⇒ Boolean
-
#initialize(contents, cursor_x: 0, cursor_y: 0, width: nil, height: nil, cursor_visible: true) ⇒ Capture
constructor
A new instance of Capture.
- #row(row) ⇒ Object
- #rows ⇒ Object
- #to_s ⇒ Object
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_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 |
#height ⇒ Object (readonly)
Returns the value of attribute height.
6 7 8 |
# File 'lib/ttytest/capture.rb', line 6 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
6 7 8 |
# File 'lib/ttytest/capture.rb', line 6 def width @width end |
Instance Method Details
#capture ⇒ Object
35 36 37 |
# File 'lib/ttytest/capture.rb', line 35 def capture self end |
#cursor_hidden? ⇒ Boolean
31 32 33 |
# File 'lib/ttytest/capture.rb', line 31 def cursor_hidden? !cursor_visible? end |
#cursor_visible? ⇒ 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 |
#rows ⇒ Object
19 20 21 |
# File 'lib/ttytest/capture.rb', line 19 def rows @rows end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/ttytest/capture.rb', line 39 def to_s rows.join("\n") end |