class YARD::I18n::Messages
Acts as a container for {Message} objects.
@since 0.8.1
Attributes
@return [Hash{String=>Message}] the set of message objects
Public Class Methods
Source
# File lib/yard/i18n/messages.rb, line 11 def initialize @messages = {} end
Creates a new container.
Public Instance Methods
Source
# File lib/yard/i18n/messages.rb, line 45 def ==(other) other.is_a?(self.class) && @messages == other.messages end
Checks if this messages list is equal to another messages list.
@param [Messages] other the container to compare. @return [Boolean] whether self
and other
is equivalence or not.
Source
# File lib/yard/i18n/messages.rb, line 27 def [](id) @messages[id] end
@param [String] id the message ID to perform a lookup on. @return [Message, nil] a registered message for the given id
,
or nil if no message for the ID is found.
Source
# File lib/yard/i18n/messages.rb, line 20 def each(&block) @messages.each_value(&block) end
Enumerates each {Message} in the container.
@yieldparam [Message] message the next message object in
the enumeration.
@return [void]
Source
# File lib/yard/i18n/messages.rb, line 37 def register(id) @messages[id] ||= Message.new(id) end
Registers a {Message}, the message ID of which is id
. If corresponding Message
is already registered, the previously registered object is returned.
@param [String] id the ID of the message to be registered. @return [Message] the registered Message
.