Sha256: 416b42bddda9ba4ad8ebe1f1b52441a7d658123519eef559ab8c551a0feab478

Contents?: true

Size: 1.67 KB

Versions: 43

Compression:

Stored size: 1.67 KB

Contents

# frozen_string_literal: true
require "set"

module YARD
  module I18n
    # +Message+ is a translation target message. It has message ID as
    # {#id} and some properties {#locations} and {#comments}.
    #
    # @since 0.8.1
    class Message
      # @return [String] the message ID of the trnslation target message.
      attr_reader :id

      # @return [Set] the set of locations. Location is an array of
      # path and line number where the message is appeared.
      attr_reader :locations

      # @return [Set] the set of comments for the messages.
      attr_reader :comments

      # Creates a trasnlate target message for message ID +id+.
      #
      # @param [String] id the message ID of the translate target message.
      def initialize(id)
        @id = id
        @locations = Set.new
        @comments = Set.new
      end

      # Adds location information for the message.
      #
      # @param [String] path the path where the message appears.
      # @param [Integer] line the line number where the message appears.
      # @return [void]
      def add_location(path, line)
        @locations << [path, line]
      end

      # Adds a comment for the message.
      #
      # @param [String] comment the comment for the message to be added.
      # @return [void]
      def add_comment(comment)
        @comments << comment unless comment.nil?
      end

      # @param [Message] other the +Message+ to be compared.
      # @return [Boolean] checks whether this message is equal to another.
      def ==(other)
        other.is_a?(self.class) &&
          @id == other.id &&
          @locations == other.locations &&
          @comments == other.comments
      end
    end
  end
end

Version data entries

43 entries across 42 versions & 7 rubygems

Version Path
kinetic_sdk-5.0.25 gems/yard-0.9.25/lib/yard/i18n/message.rb
kinetic_sdk-5.0.24 gems/yard-0.9.25/lib/yard/i18n/message.rb
kinetic_sdk-5.0.23 gems/yard-0.9.25/lib/yard/i18n/message.rb
kinetic_sdk-5.0.22 gems/yard-0.9.25/lib/yard/i18n/message.rb
kinetic_sdk-5.0.21 gems/yard-0.9.25/lib/yard/i18n/message.rb
devcycle-ruby-server-sdk-2.0.0 vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/i18n/message.rb
kinetic_sdk-5.0.20 gems/yard-0.9.25/lib/yard/i18n/message.rb
yard-0.9.28 lib/yard/i18n/message.rb
yard-0.9.27 lib/yard/i18n/message.rb
yard-0.9.26 lib/yard/i18n/message.rb
qiita_org-0.1.35 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/i18n/message.rb
qiita_org-0.1.34 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/i18n/message.rb
qiita_org-0.1.33 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/i18n/message.rb
qiita_org-0.1.32 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/i18n/message.rb
qiita_org-0.1.31 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/i18n/message.rb
qiita_org-0.1.30 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/i18n/message.rb
qiita_org-0.1.29 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/i18n/message.rb
qiita_org-0.1.28 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/i18n/message.rb
qiita_org-0.1.27 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/i18n/message.rb
qiita_org-0.1.26 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/i18n/message.rb