Class: Logger

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verbose = nil, output = nil) ⇒ Logger

Returns a new instance of Logger.



5
6
7
8
9
# File 'lib/raramorph/logger.rb', line 5

def initialize(verbose = nil  , output = nil )
   @verbose = verbose
@output = output
@stream = StringIO.new
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



4
5
6
# File 'lib/raramorph/logger.rb', line 4

def output
  @output
end

#verboseObject (readonly)

Returns the value of attribute verbose.



4
5
6
# File 'lib/raramorph/logger.rb', line 4

def verbose
  @verbose
end

Instance Method Details

#info(string, require_verbose = false) ⇒ Object



11
12
13
# File 'lib/raramorph/logger.rb', line 11

def info string , require_verbose = false
  @stream.puts(string) #if (  require_verbose && @verbose  || ! require_verbose )  
end

#logObject



15
16
17
18
19
# File 'lib/raramorph/logger.rb', line 15

def log
  return  puts @stream.string  if @output.nil? 
	File.open(@output , "w") { |f| 
f.puts @stream.string }
end