Created CursorMover (markdown)

VetheonGames 2023-06-08 11:30:59 -06:00
parent d07bfc1d68
commit 0a8cbe207c

22
CursorMover.md Normal file

@ -0,0 +1,22 @@
# CursorMover Class
The `CursorMover` class is responsible for moving the cursor position in the DynamicCursesInput gem. It provides methods to move the cursor to the left or to the right.
## Methods
### .left(cursor_pos)
This is a class method that moves the cursor one position to the left. It takes one parameter:
- `cursor_pos`: the current cursor position.
If the cursor is already at the start of the line (i.e., `cursor_pos` is zero), it does not change the cursor position. Otherwise, it decreases the cursor position by 1.
### .right(cursor_pos, length)
This is a class method that moves the cursor one position to the right. It takes two parameters:
- `cursor_pos`: the current cursor position.
- `length`: the length of the input string.
If the cursor is already at the end of the line (i.e., `cursor_pos` is equal to `length`), it does not change the cursor position. Otherwise, it increases the cursor position by 1.