class Nucleon::Core

Attributes

logger[R]
ui[R]

Public Class Methods

logger() click to toggle source
# File lib/core/core.rb, line 44
def self.logger
  return @@logger
end
new(data = {}, defaults = {}, force = true, set_initialized = true) click to toggle source
# File lib/core/core.rb, line 17
def initialize(data = {}, defaults = {}, force = true, set_initialized = true)
  super(data, defaults, force)   
  
  @class_color = Util::Data.ensure_value(delete(:class_color, :cyan), :cyan)
  @class_label = self.class.to_s.downcase.gsub(/^nucleon::/, '')
  
  self.logger = delete(:logger, @class_label)
  self.ui     = Config.new(export).defaults({ :resource => Util::Console.colorize(@class_label, @class_color) })
  
  logger.debug('Initialized instance logger and interface')
  @initialized = true if set_initialized
end
ui() click to toggle source
# File lib/core/core.rb, line 60
def self.ui
  return @@ui
end
ui_group(resource, color = :cyan) { |ui| ... } click to toggle source
# File lib/core/core.rb, line 75
def self.ui_group(resource, color = :cyan)
  @@ui_lock.synchronize do
    begin
      ui_resource = ui.resource
      ui.resource = Util::Console.colorize(resource, color)
      yield(ui)
  
    ensure
      ui.resource = ui_resource
    end
  end  
end

Public Instance Methods

initialized?() click to toggle source
# File lib/core/core.rb, line 33
def initialized?
  @initialized
end
logger=(logger) click to toggle source
# File lib/core/core.rb, line 48
def logger=logger
  Util::Logger.loggers.delete(self.logger.resource) if self.logger
  
  if logger.is_a?(Util::Logger)
    @logger = logger
  else
    @logger = Util::Logger.new(logger)
  end
end
ui=(ui) click to toggle source
# File lib/core/core.rb, line 64
def ui=ui
  if ui.is_a?(Util::Console)
    @ui = ui
  else
    @ui = Util::Console.new(ui)
  end  
end
ui_group(resource, color = :cyan) { |ui| ... } click to toggle source
# File lib/core/core.rb, line 90
def ui_group(resource, color = :cyan)
  ui_resource = ui.resource
  ui.resource = Util::Console.colorize(resource, color)
  yield(ui)
  
ensure
  ui.resource = ui_resource  
end