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:

  • 0.8.1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Message

Creates a trasnlate target message for message ID id.

Since:

  • 0.8.1



24
25
26
27
28
# 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 the set of comments for the messages.

Since:

  • 0.8.1



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

def comments
  @comments
end

#idString (readonly)

Returns the message ID of the trnslation target message.

Since:

  • 0.8.1



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

def id
  @id
end

#locationsSet (readonly)

path and line number where the message is appeared.

Since:

  • 0.8.1



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

def locations
  @locations
end

Instance Method Details

#==(other) ⇒ Boolean

Returns checks whether this message is equal to another.

Since:

  • 0.8.1



49
50
51
52
53
54
# 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.

Since:

  • 0.8.1



43
44
45
# 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.

Since:

  • 0.8.1



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

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