class ManBook::Formatter

Attributes

man_page[R]
man_page_file[R]

Public Class Methods

new(man_page) click to toggle source
# File lib/manbook/formatter.rb, line 3
def initialize(man_page)
  @man_page = man_page
  begin
    @man_page_file = execute("man -w #{man_page}").chomp!
  rescue ManBook::CommandFailedError => e
    raise ManBook::ManPageNotFoundError.new(e.msg)
  end

  ManBook.logger.debug("Located man page at #{@man_page_file}")
end

Protected Instance Methods

execute(cmd) click to toggle source
# File lib/manbook/formatter.rb, line 17
def execute(cmd)
  out, err = nil
  status = Open4::popen4(cmd){|pid, stdin, stdout, stderr|
    out = stdout.read
    err = stderr.read
  }
  raise ManBook::CommandFailedError.new(cmd, err.chomp) if 0 != status # $?
  out
end