V
Venkat Akkineni
Hi
I have created a class with a class method. I am trying to call it
from a different class and I get the "uninitialized constant" error.
Could some body help me out.
# To change this template, choose Tools | Templates
# and open the template in the editor.
require "log4r/logger"
class XELogger < Log4r::Logger
def XELogger.get(fullname)
begin
return self.superclass.get(fullname)
rescue NameError
return Log4r::Logger.new(fullname , nil , true , false)
end
end
end
# To change this template, choose Tools | Templates
# and open the template in the editor.
#require "rubygems"
require "webrick"
require "log4r"
require "monitor"
#require "XELogger"
require "rexml/document"
class XmlEngine < WEBrick::HTTPServlet::FileHandler
include MonitorMixin
# this is a BigNum
@@serialVersionUID = 1
# @xmlParser
# @htmlParsers
@hasXmlTemplate
@stcRead
@formatHashtable
@replaceHashtable
# @strDriverDefault
# @strUrlDefault
# @strBaseLocation
# @strFormatFile
# @fileXmlEngineFormat
# @fileBaseLocation
# @sessionLanguage
# @strReplaceWhat
# @strReplaceWith
# @isResource = false
# @configXMLEngine
# These loggers (xmlEngine and reloadXml) should be instantated before
they can
# used.
@@log4rXmlEngine = XELogger.get['xmlEngine']
# @@log4rReloadXml = XELogger.get('reloadXml')
# Constructor
# ToDo: Assign this argument to the instance variable
"connectionProvider"
def initialize(connectionProvider)
init
end
# Will configure log4r from the xml configure file passed
# The file object can be just the name of the file if the
# file is in the same folder, if otherwise file object
# should be a complete path to file's location.
# ToDo: Needs Tesing.
def self.configureLog4r(file)
if file !=nil
Configurator.load_xml_file(file)
else
Configurator.load_xml_file(log4r.xml)
end
end
# Courtesy of:
http://rubynugs.blogspot.com/2006/12/creating-java-like-main-method-in-ruby.html
# do
# if __FILE__ == $0 && ARGV.length < 1
# @i
# configureLog4r(nil)
# @strFile
#
# puts "main"
#
# else if __FILE__ == $0 && ARGV.length > 1
#
#
# end
#
# end
# XmlEngineNP: classes for compatibilizing with the Reports version
def readReportConfiguration(strReportFile)
end
def readReportConfiguration(strReportFile, *discard)
end
# # Log4r::Logger's get method throws a NameError when it cannot find
the
# # specified log file. This method will help create a new log file
when
# # one doesn't exist. ToDo: Create a subclass of Logger class and
override
# # the Logger class's get method.
# def fetchLogger(_name)
# begin
# return @newLogFile = Log4r::Logger.get(_name)
# rescue NameError
# return @newLogFile = Log4r::Logger.new(_name , nil , true ,
false)
# end
# end
end
I have created a class with a class method. I am trying to call it
from a different class and I get the "uninitialized constant" error.
Could some body help me out.
Class with class method
# To change this template, choose Tools | Templates
# and open the template in the editor.
require "log4r/logger"
class XELogger < Log4r::Logger
def XELogger.get(fullname)
begin
return self.superclass.get(fullname)
rescue NameError
return Log4r::Logger.new(fullname , nil , true , false)
end
end
end
Calling class
# To change this template, choose Tools | Templates
# and open the template in the editor.
#require "rubygems"
require "webrick"
require "log4r"
require "monitor"
#require "XELogger"
require "rexml/document"
class XmlEngine < WEBrick::HTTPServlet::FileHandler
include MonitorMixin
# this is a BigNum
@@serialVersionUID = 1
# @xmlParser
# @htmlParsers
@hasXmlTemplate
@stcRead
@formatHashtable
@replaceHashtable
# @strDriverDefault
# @strUrlDefault
# @strBaseLocation
# @strFormatFile
# @fileXmlEngineFormat
# @fileBaseLocation
# @sessionLanguage
# @strReplaceWhat
# @strReplaceWith
# @isResource = false
# @configXMLEngine
# These loggers (xmlEngine and reloadXml) should be instantated before
they can
# used.
@@log4rXmlEngine = XELogger.get['xmlEngine']
# @@log4rReloadXml = XELogger.get('reloadXml')
# Constructor
# ToDo: Assign this argument to the instance variable
"connectionProvider"
def initialize(connectionProvider)
init
end
# Will configure log4r from the xml configure file passed
# The file object can be just the name of the file if the
# file is in the same folder, if otherwise file object
# should be a complete path to file's location.
# ToDo: Needs Tesing.
def self.configureLog4r(file)
if file !=nil
Configurator.load_xml_file(file)
else
Configurator.load_xml_file(log4r.xml)
end
end
# Courtesy of:
http://rubynugs.blogspot.com/2006/12/creating-java-like-main-method-in-ruby.html
# do
# if __FILE__ == $0 && ARGV.length < 1
# @i
# configureLog4r(nil)
# @strFile
#
# puts "main"
#
# else if __FILE__ == $0 && ARGV.length > 1
#
#
# end
#
# end
# XmlEngineNP: classes for compatibilizing with the Reports version
def readReportConfiguration(strReportFile)
end
def readReportConfiguration(strReportFile, *discard)
end
# # Log4r::Logger's get method throws a NameError when it cannot find
the
# # specified log file. This method will help create a new log file
when
# # one doesn't exist. ToDo: Create a subclass of Logger class and
override
# # the Logger class's get method.
# def fetchLogger(_name)
# begin
# return @newLogFile = Log4r::Logger.get(_name)
# rescue NameError
# return @newLogFile = Log4r::Logger.new(_name , nil , true ,
false)
# end
# end
end