Method: Enumerable#pp_s

Defined in:
lib/jinx/helpers/pretty_print.rb

#pp_s(opts = nil) {|item| ... } ⇒ Object

If a transformer block is given to this method, then the block is applied to each enumerated item before pretty-printing the result.

Parameters:

  • opts (Hash, Symbol, nil) (defaults to: nil)

    the print options

Yields:

  • (item)

    transforms the item to print

Yield Parameters:

  • item

    the item to print



132
133
134
135
136
137
138
139
# File 'lib/jinx/helpers/pretty_print.rb', line 132

def pp_s(opts=nil)
  # delegate to Object if no block
  return super unless block_given?
  # make a print wrapper
  wrapper = PrintWrapper.new { |item| yield item }
  # print using the wrapper on each item
  wrap { |item| wrapper.wrap(item) }.pp_s(opts)
end