# Class: Tgio::Output::Pager

This class provides class methods for paging and an object which can conditionally page given a terminal size that is exceeded. adapted from Hirb gem: credit to Gabriel Horner

# Attributes

Name | Read/write?
--- | ---
height | R
width | R

# Public Class Methods

### default_pager (output, options={})

Pages with a ruby-only pager which either pages, displays remaining or quits.

Show source...

        # File bbs/lib/tgio/output.rb, line 65
    65:         def default_pager(output, options={})
    66:           pager = new(options[:width], options[:height])
    67:           while pager.activated_by?(output)
    68:             puts pager.slice!(output)
    69:             pt = Tgtemplate::Template.new('pager_default.ftl').stringify.chomp
    70:             print pt
    71:             prompt = Tgio::Input.pagerkey_default
    72:             if prompt.upcase == 'N'
    73:               return
    74:             elsif prompt.upcase == 'Y'
    75:               print " \b\b \b" * (pt.length + 1)
    76:             elsif prompt.upcase == 'Q'
    77:               #TODO: Quit paging and display remaining text
    78:             end
    79:             #return unless continue_paging?
    80:           end
    81:           puts output
    82:         end

### new (width=80, height=24)

Create a new instance of Pager with defaults

Show source...

         # File bbs/lib/tgio/output.rb, line 109
    109:       def initialize(width=80, height=24)
    110:         resize(width, height)
    111:       end

# Public Instance Methods

### activated_by? (string_to_page)

Determines if string should be paged based on configured width and height.

Show source...

         # File bbs/lib/tgio/output.rb, line 128
    128:       def activated_by?(string_to_page)
    129:         string_to_page.count("\n") > @height
    130:       end

### page (string)

Pages given string using configured pager.

Show source...

         # File bbs/lib/tgio/output.rb, line 114
    114:       def page(string)
    115:         self.class.default_pager(string, :width=>@width, :height=>@height)
    116:         string.replace("") # Blank String to clear for next run
    117:       end