module Ripl::FormatResult

Allows [Ripl](github.com/cldwalker/ripl) to wrap lines of output and/or prefix each line of the result with the `result_prompt`.

Public Class Methods

format_result(result,conf={}) click to toggle source

@private no need to document the method

# File lib/ruic/ripl.rb, line 33
def format_result(result,conf={})
        conf=config if respond_to? :config
        result = conf[:to_s] ? result.to_s : result.inspect
        result = result.dup if result.frozen?
        if limit=conf[:result_line_limit]
                match = /^.{#{limit}}.+/o
                :go while result.sub!(match){ |line| line.sub /^(?:(.{,#{limit}})[ \t]+|(.{#{limit}}))/o, "\\1\\2\n" }
        end

        result.gsub( conf[:prefix_result_lines] ? /^/ : /\A/, conf[:result_prompt] )
end

Private Instance Methods

format_result(result,conf={}) click to toggle source

@private no need to document the method

# File lib/ruic/ripl.rb, line 33
def format_result(result,conf={})
        conf=config if respond_to? :config
        result = conf[:to_s] ? result.to_s : result.inspect
        result = result.dup if result.frozen?
        if limit=conf[:result_line_limit]
                match = /^.{#{limit}}.+/o
                :go while result.sub!(match){ |line| line.sub /^(?:(.{,#{limit}})[ \t]+|(.{#{limit}}))/o, "\\1\\2\n" }
        end

        result.gsub( conf[:prefix_result_lines] ? /^/ : /\A/, conf[:result_prompt] )
end