Class: JarEd::Buffer
- Inherits:
-
Object
- Object
- JarEd::Buffer
- Defined in:
- lib/jared/buffer.rb
Instance Attribute Summary collapse
-
#cursor_column ⇒ Object
readonly
Returns the value of attribute cursor_column.
-
#cursor_row ⇒ Object
readonly
Returns the value of attribute cursor_row.
-
#window_position ⇒ Object
readonly
Returns the value of attribute window_position.
Instance Method Summary collapse
- #cursor(rows, columns) ⇒ Object
-
#initialize(file) ⇒ Buffer
constructor
A new instance of Buffer.
- #lines ⇒ Object
Constructor Details
#initialize(file) ⇒ Buffer
Returns a new instance of Buffer.
7 8 9 10 11 12 |
# File 'lib/jared/buffer.rb', line 7 def initialize(file) @file = file @window_position = 0 @cursor_row = 0 @cursor_column = 0 end |
Instance Attribute Details
#cursor_column ⇒ Object (readonly)
Returns the value of attribute cursor_column.
3 4 5 |
# File 'lib/jared/buffer.rb', line 3 def cursor_column @cursor_column end |
#cursor_row ⇒ Object (readonly)
Returns the value of attribute cursor_row.
3 4 5 |
# File 'lib/jared/buffer.rb', line 3 def cursor_row @cursor_row end |
#window_position ⇒ Object (readonly)
Returns the value of attribute window_position.
3 4 5 |
# File 'lib/jared/buffer.rb', line 3 def window_position @window_position end |
Instance Method Details
#cursor(rows, columns) ⇒ Object
19 20 21 22 |
# File 'lib/jared/buffer.rb', line 19 def cursor(rows, columns) @cursor_row = [0, cursor_row + rows].max @cursor_column = [0, cursor_column + columns].max end |
#lines ⇒ Object
14 15 16 |
# File 'lib/jared/buffer.rb', line 14 def lines @lines ||= file.each_line.to_a end |