Class: Util::ReportStream

Inherits:
Object
  • Object
show all
Defined in:
../lib/report.rb

Overview

Reporting helper class. The Report instance provides the simple interface for reporting the internal values and progression during the evolutionary algorithm’s run. The output is sent to the stream.

Instance Method Summary (collapse)

Constructor Details

- (ReportStream) initialize(stream = $stdout)

Attach the reporter to the specific stream. The default stream is STDOUT.



93
94
95
# File '../lib/report.rb', line 93

def initialize stream=$stdout
  @stream = stream
end

Instance Method Details

- (Object) <<(line)

Report the status (mostly textual) info for the current step. For example:


  r = ReportStream.new 
  r << "this line is displayed"


100
101
102
# File '../lib/report.rb', line 100

def << line
  @stream.puts line
end

- (Object) [](label)

Report an information under the label. For instance:


  r['maxfitness'] << 42
  r['diversity'] << 'sufficient'

prints:


  maxfitness: 42
  diversity: sufficient 

into the stream.



111
112
113
114
# File '../lib/report.rb', line 111

def [] label 
  @stream.print "#{label}: "
  self
end

- (Object) next

Do nothing (compatible with the ReportText class).



117
118
# File '../lib/report.rb', line 117

def next
end

- (Object) output

Produce an empty string (compatible with the ReportText class).



121
122
123
# File '../lib/report.rb', line 121

def output
  ''
end