Class: TTY::Terminal::BasicPager

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

Overview

A class responsible for paging text

Constant Summary collapse

PROMPT_HEIGHT =
3
PAGE_BREAK =
"--- Press enter/return to continue (or q to quit) ---"

Instance Attribute Summary

Attributes inherited from Pager

#enabled, #text

Instance Method Summary collapse

Methods inherited from Pager

available, available?, command, #enabled?, executables, #initialize, page

Constructor Details

This class inherits a constructor from TTY::Terminal::Pager

Instance Method Details

#pageObject

Use ruby to page output text



16
17
18
19
20
21
22
23
24
# File 'lib/tty/terminal/pager/basic.rb', line 16

def page
  text_lines = text.lines.to_a

  text_lines.each_slice(page_size) do |chunk|
    TTY.shell.say chunk.join
    break if chunk.size < page_size
    break if !continue?(text_lines)
  end
end