Class: RDoc::Generator::POT::POEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/rdoc/generator/pot/po_entry.rb

Overview

A PO entry in PO

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msgid, options = {}) ⇒ POEntry

Creates a PO entry for msgid. Other values can be specified by options.



32
33
34
35
36
37
38
39
# File 'lib/rdoc/generator/pot/po_entry.rb', line 32

def initialize(msgid, options = {})
  @msgid = msgid
  @msgstr = options[:msgstr] || ""
  @translator_comment = options[:translator_comment]
  @extracted_comment = options[:extracted_comment]
  @references = options[:references] || []
  @flags = options[:flags] || []
end

Instance Attribute Details

#extracted_comment ⇒ Object (readonly)

The comment content extracted from source file



20
21
22
# File 'lib/rdoc/generator/pot/po_entry.rb', line 20

def extracted_comment
  @extracted_comment
end

#flags ⇒ Object (readonly)

The flags of the PO entry



26
27
28
# File 'lib/rdoc/generator/pot/po_entry.rb', line 26

def flags
  @flags
end

#msgid ⇒ Object (readonly)

The msgid content



11
12
13
# File 'lib/rdoc/generator/pot/po_entry.rb', line 11

def msgid
  @msgid
end

#msgstr ⇒ Object (readonly)

The msgstr content



14
15
16
# File 'lib/rdoc/generator/pot/po_entry.rb', line 14

def msgstr
  @msgstr
end

#references ⇒ Object (readonly)

The locations where the PO entry is extracted



23
24
25
# File 'lib/rdoc/generator/pot/po_entry.rb', line 23

def references
  @references
end

#translator_comment ⇒ Object (readonly)

The comment content created by translator (PO editor)



17
18
19
# File 'lib/rdoc/generator/pot/po_entry.rb', line 17

def translator_comment
  @translator_comment
end

Instance Method Details

#merge(other_entry) ⇒ Object

Merges the PO entry with other_entry.



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rdoc/generator/pot/po_entry.rb', line 59

def merge(other_entry)
  options = {
    :extracted_comment  => merge_string(@extracted_comment,
                                        other_entry.extracted_comment),
    :translator_comment => merge_string(@translator_comment,
                                        other_entry.translator_comment),
    :references         => merge_array(@references,
                                       other_entry.references),
    :flags              => merge_array(@flags,
                                       other_entry.flags),
  }
  self.class.new(@msgid, options)
end

#to_s ⇒ Object

Returns the PO entry in PO format.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rdoc/generator/pot/po_entry.rb', line 44

def to_s
  entry = ''
  entry += format_translator_comment
  entry += format_extracted_comment
  entry += format_references
  entry += format_flags
  entry += <<-ENTRY
msgid #{format_message(@msgid)}
msgstr #{format_message(@msgstr)}
    ENTRY
end