Class: CoopAl::Trace

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/coop_al/trace.rb

Overview

Trace

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTrace

Returns a new instance of Trace.



12
13
14
15
# File 'lib/coop_al/trace.rb', line 12

def initialize
  @tracing = false
  @stream = STDOUT
end

Instance Attribute Details

#stream=(value) ⇒ Object (writeonly)

Sets the attribute stream

Parameters:

  • value

    the value to set the attribute stream to.



10
11
12
# File 'lib/coop_al/trace.rb', line 10

def stream=(value)
  @stream = value
end

#tracing=(value) ⇒ Object (writeonly)

Sets the attribute tracing

Parameters:

  • value

    the value to set the attribute tracing to.



10
11
12
# File 'lib/coop_al/trace.rb', line 10

def tracing=(value)
  @tracing = value
end

Instance Method Details

#error(s) ⇒ Object



25
26
27
# File 'lib/coop_al/trace.rb', line 25

def error(s)
  @stream.puts("[ERROR] #{s}") if @tracing
end

#info(s) ⇒ Object



17
18
19
# File 'lib/coop_al/trace.rb', line 17

def info(s)
  @stream.puts(s) if @tracing
end

#warn(s) ⇒ Object



21
22
23
# File 'lib/coop_al/trace.rb', line 21

def warn(s)
  @stream.puts("[WARNING] #{s}") if @tracing
end