Class: AdLint::MessageCatalog

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

Overview

DESCRIPTION

Message catalog.

Instance Method Summary collapse

Constructor Details

#initialize(traits) ⇒ MessageCatalog

Returns a new instance of MessageCatalog.



448
449
450
451
452
# File 'lib/adlint/message.rb', line 448

def initialize(traits)
  @traits = traits
  @hash = Hash.new
  message_definition_files.each { |def_file| def_file.read_into(self) }
end

Instance Method Details

#lookup(msg_id) ⇒ Object



454
455
456
# File 'lib/adlint/message.rb', line 454

def lookup(msg_id)
  @hash[msg_id] or raise InvalidMessageIdError.new(msg_id)
end

#merge!(pkg_name, msg_def) ⇒ Object



458
459
460
461
462
463
464
465
466
467
# File 'lib/adlint/message.rb', line 458

def merge!(pkg_name, msg_def)
  msg_def.each do |msg_name_str, cont|
    msg_id = MessageId.new(pkg_name, msg_name_str.to_sym)
    if changed = @traits.of_message.change_list[msg_id]
      cont = changed
    end
    @hash[msg_id] =
      MessageTemplate.new(msg_id, cont["classes"], cont["format"])
  end
end