Class: TTY::Pager::BasicPager::PageCursor Private

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/pager/basic.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Tracks page cursor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(height) ⇒ PageCursor

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PageCursor.


97
98
99
100
# File 'lib/tty/pager/basic.rb', line 97

def initialize(height)
  @height = height
  reset
end

Instance Attribute Details

#page_numObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


95
96
97
# File 'lib/tty/pager/basic.rb', line 95

def page_num
  @page_num
end

Instance Method Details

#down_by(count) ⇒ Object

Move coursor down the page by count

Parameters:

  • count (Integer)

120
121
122
# File 'lib/tty/pager/basic.rb', line 120

def down_by(count)
  @lines_left -= count
end

#next_pageObject

Move cursor to the next page


110
111
112
113
# File 'lib/tty/pager/basic.rb', line 110

def next_page
  @page_num += 1
  @lines_left = @height
end

#page_break?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check if time to break a page

Returns:

  • (Boolean)

129
130
131
# File 'lib/tty/pager/basic.rb', line 129

def page_break?
  @lines_left.zero?
end

#resetObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


102
103
104
105
# File 'lib/tty/pager/basic.rb', line 102

def reset
  @page_num = 1
  @lines_left = @height
end