Class: YARD::I18n::Message

Inherits:
Object
  • Object
show all
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:

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Message) initialize(id)

Creates a trasnlate target message for message ID id.

Parameters:

  • id (String)

    the message ID of the translate target message.

Since:

  • 0.8.1



23
24
25
26
27
# File 'lib/yard/i18n/message.rb', line 23

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

Instance Attribute Details

- (Set) comments (readonly)

Returns the set of comments for the messages.

Returns:

  • (Set)

    the set of comments for the messages.

Since:

  • 0.8.1



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

def comments
  @comments
end

- (String) id (readonly)

Returns the message ID of the trnslation target message.

Returns:

  • (String)

    the message ID of the trnslation target message.

Since:

  • 0.8.1



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

def id
  @id
end

- (Set) locations (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



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

def locations
  @locations
end

Instance Method Details

- (Boolean) ==(other)

Returns checks whether this message is equal to another.

Parameters:

  • other (Message)

    the Message to be compared.

Returns:

  • (Boolean)

    checks whether this message is equal to another.

Since:

  • 0.8.1



48
49
50
51
52
53
# File 'lib/yard/i18n/message.rb', line 48

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

- (void) add_comment(comment)

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



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

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

- (void) add_location(path, line)

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



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

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