Sha256: fdce26f9804aa6cef89697083b3b245027ee8170690f13f791b101fff565e7fe

Contents?: true

Size: 1.51 KB

Versions: 75

Compression:

Stored size: 1.51 KB

Contents

module YARD
  module I18n
    # Acts as a container for {Message} objects.
    #
    # @since 0.8.1
    class Messages
      include Enumerable

      # Creates a new container.
      def initialize
        @messages = {}
      end

      # Enumerates each {Message} in the container.
      #
      # @yieldparam [Message] message the next message object in
      #   the enumeration.
      # @return [void]
      def each(&block)
        @messages.each_value(&block)
      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.
      def [](id)
        @messages[id]
      end

      # Registers a {Message}, the mssage 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+.
      def register(id)
        @messages[id] ||= Message.new(id)
      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.
      def ==(other)
        other.is_a?(self.class) and
          @messages == other.messages
      end

      protected

      # @return [Hash{String=>Message}] the set of message objects
      attr_reader :messages
    end
  end
end

Version data entries

75 entries across 58 versions & 8 rubygems

Version Path
abaci-0.3.0 vendor/bundle/gems/yard-0.9.1/lib/yard/i18n/messages.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.2/lib/yard/i18n/messages.rb
yard-0.9.5 lib/yard/i18n/messages.rb
yard-0.9.4 lib/yard/i18n/messages.rb
yard-0.9.3 lib/yard/i18n/messages.rb
yard-0.9.2 lib/yard/i18n/messages.rb
yard-0.9.1 lib/yard/i18n/messages.rb
yard-0.9.0 lib/yard/i18n/messages.rb
yard-0.8.7.6 lib/yard/i18n/messages.rb
yard-0.8.7.5 lib/yard/i18n/messages.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/i18n/messages.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/yard-0.8.7.3/lib/yard/i18n/messages.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/i18n/messages.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/i18n/messages.rb
yard-0.8.7.4 lib/yard/i18n/messages.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/i18n/messages.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/i18n/messages.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/yard-0.8.7.3/lib/yard/i18n/messages.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/i18n/messages.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/i18n/messages.rb