123456789_123456789_123456789_123456789_123456789_

Class: YARD::I18n::Messages

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Enumerable
Inherits: Object
Defined in: lib/yard/i18n/messages.rb

Overview

Acts as a container for Message objects.

Since:

  • 0.8.1

Class Method Summary

Instance Method Summary

Constructor Details

.newMessages

Creates a new container.

Since:

  • 0.8.1

[ GitHub ]

  
# File 'lib/yard/i18n/messages.rb', line 11

def initialize
  @messages = {}
end

Instance Method Details

#==(other) ⇒ Boolean

Checks if this messages list is equal to another messages list.

Parameters:

  • other (Messages)

    the container to compare.

Returns:

  • (Boolean)

    whether self and other is equivalence or not.

Since:

  • 0.8.1

[ GitHub ]

  
# File 'lib/yard/i18n/messages.rb', line 45

def ==(other)
  other.is_a?(self.class) &&
    @messages == other.messages
end

#[](id) ⇒ Message?

Parameters:

  • id (String)

    the message ID to perform a lookup on.

Returns:

  • (Message, nil)

    a registered message for the given id, or nil if no message for the ID is found.

Since:

  • 0.8.1

[ GitHub ]

  
# File 'lib/yard/i18n/messages.rb', line 27

def [](id)
  @messages[id]
end

#each {|message| ... } ⇒ void

This method returns an undefined value.

Enumerates each Message in the container.

Yield Parameters:

  • message (Message)

    the next message object in the enumeration.

Since:

  • 0.8.1

[ GitHub ]

  
# File 'lib/yard/i18n/messages.rb', line 20

def each(&block)
  @messages.each_value(&block)
end

#register(id) ⇒ Message

Registers a Message, the message ID of which is id. If corresponding Message is already registered, the previously registered object is returned.

Parameters:

  • id (String)

    the ID of the message to be registered.

Returns:

Since:

  • 0.8.1

[ GitHub ]

  
# File 'lib/yard/i18n/messages.rb', line 37

def register(id)
  @messages[id] ||= Message.new(id)
end