Class: YARD::I18n::Messages
- Inherits:
-
Object
- Object
- YARD::I18n::Messages
- Includes:
- Enumerable
- Defined in:
- lib/yard/i18n/messages.rb
Overview
Acts as a container for Message objects.
Instance Attribute Summary collapse
-
#messages ⇒ Hash{String=>Message}
readonly
protected
The set of message objects.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Checks if this messages list is equal to another messages list.
-
#[](id) ⇒ Message?
A registered message for the given
id
, or nil if no message for the ID is found. -
#each {|message| ... } ⇒ void
Enumerates each Message in the container.
-
#initialize ⇒ Messages
constructor
Creates a new container.
-
#register(id) ⇒ Message
Registers a Message, the message ID of which is
id
.
Constructor Details
#initialize ⇒ Messages
Creates a new container.
11 12 13 |
# File 'lib/yard/i18n/messages.rb', line 11 def initialize @messages = {} end |
Instance Attribute Details
Instance Method Details
#==(other) ⇒ Boolean
Checks if this messages list is equal to another messages list.
45 46 47 48 |
# File 'lib/yard/i18n/messages.rb', line 45 def ==(other) other.is_a?(self.class) && @messages == other. end |
#[](id) ⇒ Message?
Returns a registered message for the given id
, or nil if no message for the ID is found.
27 28 29 |
# File 'lib/yard/i18n/messages.rb', line 27 def [](id) @messages[id] end |
#each {|message| ... } ⇒ void
This method returns an undefined value.
Enumerates each YARD::I18n::Message in the container.
20 21 22 |
# File 'lib/yard/i18n/messages.rb', line 20 def each(&block) @messages.each_value(&block) end |
#register(id) ⇒ Message
Registers a YARD::I18n::Message, the message ID of which is id
. If corresponding Message
is already registered, the previously registered object is returned.
37 38 39 |
# File 'lib/yard/i18n/messages.rb', line 37 def register(id) @messages[id] ||= Message.new(id) end |