Sha256: cfc5cfc98227c6c4243732c847600f8fb14f8611bb8fe8ddfea53765b0760f3c

Contents?: true

Size: 764 Bytes

Versions: 2

Compression:

Stored size: 764 Bytes

Contents

# Allows [Ripl](https://github.com/cldwalker/ripl) to execute code or print a message after every result.
#
# @example 1) Printing a blank line after each result
#  require_relative 'ripl-after-result'
#  Ripl::Shell.include Ripl::AfterResult
#  Ripl.config.merge! after_result:"\n"
#
# @example 2) Executing arbitrary code with the result
#  results = []
#  require_relative 'ripl-after-result'
#  Ripl::Shell.include Ripl::AfterResult
#  Ripl.config.merge! after_result:proc{ |result| results << result }
module Ripl::AfterResult
	# @private no need to document the method
	def print_result(result)
		super
		if after=config[:after_result]
			if after.respond_to?(:call)
				after.call(result)
			else
				puts after
			end
		end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
RUIC-0.4.6 lib/ruic/ripl-after-result.rb
RUIC-0.4.5 lib/ruic/ripl-after-result.rb