Class: MonoclePrint::Pager

Inherits:
OutputDevice show all
Defined in:
lib/monocle-print/output-device.rb

Constant Summary collapse

PAGER_COMMAND =
pager_command

Constants inherited from OutputDevice

OutputDevice::DEFAULT_SIZE, OutputDevice::IO_PRINT_METHODS, OutputDevice::SIZE_IOCTL, OutputDevice::SIZE_STRUCT

Constants included from TerminalEscapes

TerminalEscapes::ANSI_COLORS, TerminalEscapes::ANSI_COLOR_NAMES, TerminalEscapes::ANSI_MODIFIERS, TerminalEscapes::ANSI_MODIFIER_NAMES

Constants included from MonoclePrint

COLOR_ESCAPE, FOUR_BYTES, MULTIBYTE_CHARACTER, ONE_BYTE, THREE_BYTES, TWO_BYTES, VERSION

Instance Attribute Summary

Attributes inherited from OutputDevice

#device, #style

Class Method Summary collapse

Methods inherited from OutputDevice

#background, buffer, #clear, #clear_line, #close, #color_code, #colors, #column, #column_layout, #fill, #foreground, #full_width, #height, #indent, #initialize, #left_margin, #left_margin=, #leger, #line, #list, #margin=, #modifier, #newline!, #outdent, #print, #printf, #put, #put!, #puts, #putsf, #reset!, #return!, #right_margin, #right_margin=, #space, stderr, stdout, #table, #use_color, #use_color=, #width

Methods included from TerminalEscapes

ansi_color, ansi_modifier, blink, bold, clear_attr, clear_down, clear_left, clear_line, clear_right, clear_screen, clear_up, conceal, cursor_backward, cursor_down, cursor_forward, cursor_up, dobule_height_bottom, double_height_top, double_width, konsole_color, restore_cursor, reverse, save_cursor, set_cursor, single_width, underline, xterm_color

Methods included from MonoclePrint

Line, Output, Rectangle, Style, Text, buffer, included, library_path, stderr, stdout, version

Constructor Details

This class inherits a constructor from MonoclePrint::OutputDevice

Class Method Details

.open(options = {}) ⇒ Object



485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/monocle-print/output-device.rb', line 485

def self.open( options = {} )
  unless PAGER_COMMAND
    message = <<-END.gsub!( /\s+/, ' ' ).strip!
    unable to locate a pager program on the system's PATH or from
    the environmental variable, PAGER
    END
    raise( IOError, message )
  end

  options.fetch( :use_color ) { options[ :use_color ] = true }

  if block_given?
    IO.popen( PAGER_COMMAND, 'w' ) do | pager |
      pager = new( pager, options )
      return yield( pager )
    end
  else
    return new( IO.popen( PAGER_COMMAND, 'w' ), options )
  end
end