Parent

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 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

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.