Class: Sunsap::Reporter

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

Overview

The reporter

Instance Method Summary collapse

Constructor Details

#initialize(reportername) ⇒ Reporter

Create a new reporter

@api public
@param [reportername] the name of the reporter as a string

Examples:

Make a new reporter


reporter = Sunsap::Reporter.new("test")
# => true


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/sunsap.rb', line 18

def initialize(reportername)
  @queue = []

  # Send a message to the queue
  #
  # @api public
  # @param [m] message to send
  #
  # @example Send a message
  #
  #   reporter.send_test_message "Success!"
  #   # => true
  #
  # @returns true
  self.class.send :define_method, "send_#{reportername}_message" do |m|
    @queue.push(m)
    true
  end

  # View the queue
  #
  # @api public
  # @example Read a queue
  #
  #   reporter.queue
  #   # => ["Success!"]
  #
  # @returns Array of messages
  def queue
    @queue
  end
  true
end

Instance Method Details

#queueObject

View the queue

Examples:

Read a queue


reporter.queue
# => ["Success!"]


46
47
48
# File 'lib/sunsap.rb', line 46

def queue
  @queue
end