Class: PrintWrapper

Inherits:
Proc show all
Defined in:
lib/jinx/helpers/pretty_print.rb

Overview

A PrintWrapper prints arguments by calling a printer proc.

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ PrintWrapper

Creates a new PrintWrapper on the given arguments.



28
29
30
31
# File 'lib/jinx/helpers/pretty_print.rb', line 28

def initialize(*args)
  super()
  @args = args
end

Instance Method Details

#to_sObject Also known as: inspect

Calls this PrintWrapper’s print procedure on the arguments set in the initializer.



41
42
43
# File 'lib/jinx/helpers/pretty_print.rb', line 41

def to_s
  @args.empty? ? 'nil' : call(*@args)
end

#wrap(*args) ⇒ PrintWrapper

Returns self.

Parameters:

  • args

    this wrapper’s print block parameters

Returns:



35
36
37
38
# File 'lib/jinx/helpers/pretty_print.rb', line 35

def wrap(*args)
  @args = args
  self
end