123456789_123456789_123456789_123456789_123456789_

Class: YARD::I18n::Message

Relationships & Source Files
Inherits: Object
Defined in: lib/yard/i18n/message.rb

Overview

Message is a translation target message. It has message ID as #id and some properties #locations and #comments.

Since:

  • 0.8.1

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(id) ⇒ Message

Creates a translate target message for message ID #id.

Parameters:

  • id (String)

    the message ID of the translate target message.

Since:

  • 0.8.1

[ GitHub ]

  
# File 'lib/yard/i18n/message.rb', line 24

def initialize(id)
  @id = id
  @locations = Set.new
  @comments = Set.new
end

Instance Attribute Details

#commentsSet (readonly)

Returns:

  • (Set)

    the set of comments for the messages.

Since:

  • 0.8.1

[ GitHub ]

  
# File 'lib/yard/i18n/message.rb', line 19

attr_reader :comments

#idString (readonly)

Returns:

  • (String)

    the message ID of the translation target message.

Since:

  • 0.8.1

[ GitHub ]

  
# File 'lib/yard/i18n/message.rb', line 12

attr_reader :id

#locationsSet (readonly)

path and line number where the message is appeared.

Returns:

  • (Set)

    the set of locations. Location is an array of

Since:

  • 0.8.1

[ GitHub ]

  
# File 'lib/yard/i18n/message.rb', line 16

attr_reader :locations

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

  • other (Message)

    the Message to be compared.

Returns:

  • (Boolean)

    checks whether this message is equal to another.

Since:

  • 0.8.1

[ GitHub ]

  
# File 'lib/yard/i18n/message.rb', line 49

def ==(other)
  other.is_a?(self.class) &&
    @id == other.id &&
    @locations == other.locations &&
    @comments == other.comments
end

#add_comment(comment) ⇒ void

This method returns an undefined value.

Adds a comment for the message.

Parameters:

  • comment (String)

    the comment for the message to be added.

Since:

  • 0.8.1

[ GitHub ]

  
# File 'lib/yard/i18n/message.rb', line 43

def add_comment(comment)
  @comments << comment unless comment.nil?
end

#add_location(path, line) ⇒ void

This method returns an undefined value.

Adds location information for the message.

Parameters:

  • path (String)

    the path where the message appears.

  • line (Integer)

    the line number where the message appears.

Since:

  • 0.8.1

[ GitHub ]

  
# File 'lib/yard/i18n/message.rb', line 35

def add_location(path, line)
  @locations << [path, line]
end