Module: Outputter::InstanceMethods Private

Defined in:
lib/randomperson/outputter.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance methods

Instance Method Summary collapse

Instance Method Details

#execute(person = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Command pattern



37
38
39
# File 'lib/randomperson/outputter.rb', line 37

def execute( person=nil )
  @on_execute.call( person )
end

#on_execute(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Block to execute when instance is ready.

Examples:

# In the AmericanSuffix constructor
# Some help to make sure suffixes are age appropriate.
on_execute do |person|
  r = rand(99)      
  if person.age > 17
    r += 1 #Jr can't happen and Snr can
  end
  #
  @possibles.each_pair{|k,v| break v if k === r }
end


30
31
32
# File 'lib/randomperson/outputter.rb', line 30

def on_execute( &block )
  @on_execute = block
end