Class: Hirb::Pager

### Home Classes Methods

### In Files

- lib/hirb/pager.rb

### Parent

Object

### Methods

- ::command_pager
- ::default_pager
- ::new
- #activated_by?
- #page

### Files

- LICENSE.txt
- README.rdoc

### Class/Module Index

Quicksearch

- Hirb
- Hirb::Console
- Hirb::DynamicView
- Hirb::Formatter
- Hirb::Helpers
- Hirb::Helpers::AutoTable
- Hirb::Helpers::ObjectTable
- Hirb::Helpers::ParentChildTree
- Hirb::Helpers::Table
- Hirb::Helpers::Table::Filters
- Hirb::Helpers::Table::Resizer
- Hirb::Helpers::Table::TooManyFieldsForWidthError
- Hirb::Helpers::Tree
- Hirb::Helpers::Tree::Node
- Hirb::Helpers::Tree::Node::MissingLevelError
- Hirb::Helpers::Tree::Node::MissingValueError
- Hirb::Helpers::Tree::ParentlessNodeError
- Hirb::Helpers::VerticalTable
- Hirb::Menu
- Hirb::Menu::Error
- Hirb::ObjectMethods
- Hirb::Pager
- Hirb::String
- Hirb::Util
- Hirb::View
- Hirb::Views

No matching classes.

# Hirb::Pager

This class provides class methods for paging and an object which can conditionally page given a terminal size that is exceeded.

### Attributes

height[R]
width[R]

### Public Class Methods

command_pager(output, options={}) click to toggle source

Pages using a configured or detected shell command.

    # File lib/hirb/pager.rb, line 6
    def command_pager(output, options={})
      basic_pager(output) if valid_pager_command?(options[:pager_command])
    end

default_pager(output, options={}) click to toggle source

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

    # File lib/hirb/pager.rb, line 19
    def default_pager(output, options={})
      pager = new(options[:width], options[:height])
      while pager.activated_by?(output, options[:inspect])
        puts pager.slice!(output, options[:inspect])
        return unless continue_paging?
      end
      puts output
      puts "=== Pager finished. ==="
    end

new(width, height, options={}) click to toggle source

    # File lib/hirb/pager.rb, line 58
    def initialize(width, height, options={})
      resize(width, height)
      @pager_command = options[:pager_command] if options[:pager_command]
    end

### Public Instance Methods

activated_by?(string_to_page, inspect_mode=false) click to toggle source

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

    # File lib/hirb/pager.rb, line 87
    def activated_by?(string_to_page, inspect_mode=false)
      inspect_mode ? (String.size(string_to_page) > @height * @width) : (string_to_page.count("\n") > @height)
    end

page(string, inspect_mode) click to toggle source

Pages given string using configured pager.

    # File lib/hirb/pager.rb, line 64
    def page(string, inspect_mode)
      if self.class.valid_pager_command?(@pager_command)
        self.class.command_pager(string, :pager_command=>@pager_command)
      else
        self.class.default_pager(string, :width=>@width, :height=>@height, :inspect=>inspect_mode)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.