Class: Warg::Console::History::Entry
- Inherits:
-
Object
- Object
- Warg::Console::History::Entry
- Defined in:
- lib/warg.rb
Instance Attribute Summary collapse
-
#column_number ⇒ Object
Returns the value of attribute column_number.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#last_line_length ⇒ Object
readonly
Returns the value of attribute last_line_length.
-
#newline_count ⇒ Object
readonly
Returns the value of attribute newline_count.
-
#next_entry ⇒ Object
Returns the value of attribute next_entry.
-
#previous_entry ⇒ Object
Returns the value of attribute previous_entry.
-
#row_number ⇒ Object
Returns the value of attribute row_number.
Instance Method Summary collapse
- #end_column ⇒ Object
- #end_row ⇒ Object
-
#initialize(content, cursor_position) ⇒ Entry
constructor
A new instance of Entry.
- #inspect ⇒ Object
- #newline_count_diff ⇒ Object
- #sync! ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(content, cursor_position) ⇒ Entry
Returns a new instance of Entry.
345 346 347 348 349 350 351 352 353 354 |
# File 'lib/warg.rb', line 345 def initialize(content, cursor_position) @content = content @row_number = cursor_position.row @column_number = cursor_position.column @text = @content.to_s @newline_count = @content.newline_count @last_line_length = @content.last_line_length end |
Instance Attribute Details
#column_number ⇒ Object
Returns the value of attribute column_number.
337 338 339 |
# File 'lib/warg.rb', line 337 def column_number @column_number end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
338 339 340 |
# File 'lib/warg.rb', line 338 def content @content end |
#last_line_length ⇒ Object (readonly)
Returns the value of attribute last_line_length.
339 340 341 |
# File 'lib/warg.rb', line 339 def last_line_length @last_line_length end |
#newline_count ⇒ Object (readonly)
Returns the value of attribute newline_count.
341 342 343 |
# File 'lib/warg.rb', line 341 def newline_count @newline_count end |
#next_entry ⇒ Object
Returns the value of attribute next_entry.
340 341 342 |
# File 'lib/warg.rb', line 340 def next_entry @next_entry end |
#previous_entry ⇒ Object
Returns the value of attribute previous_entry.
342 343 344 |
# File 'lib/warg.rb', line 342 def previous_entry @previous_entry end |
#row_number ⇒ Object
Returns the value of attribute row_number.
343 344 345 |
# File 'lib/warg.rb', line 343 def row_number @row_number end |
Instance Method Details
#end_column ⇒ Object
369 370 371 372 373 374 375 376 377 |
# File 'lib/warg.rb', line 369 def end_column value = 1 + @content.last_line_length if newline_count.zero? value += @column_number end value end |
#end_row ⇒ Object
365 366 367 |
# File 'lib/warg.rb', line 365 def end_row @row_number + newline_count end |
#inspect ⇒ Object
383 384 385 |
# File 'lib/warg.rb', line 383 def inspect %{#<#{self.class.name} row_number=#{row_number} column_number=#{column_number} content=#{content.inspect}>} end |
#newline_count_diff ⇒ Object
361 362 363 |
# File 'lib/warg.rb', line 361 def newline_count_diff @content.newline_count - @newline_count end |
#sync! ⇒ Object
356 357 358 359 |
# File 'lib/warg.rb', line 356 def sync! @text = @content.to_s @last_line_length = @content.last_line_length end |
#to_s ⇒ Object
379 380 381 |
# File 'lib/warg.rb', line 379 def to_s @text.dup end |