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 valus can be specified by options.



28
29
30
31
32
33
34
35
# File 'lib/rdoc/generator/pot/po_entry.rb', line 28

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_commentObject (readonly)

The comment content extracted from source file



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

def extracted_comment
  @extracted_comment
end

#flagsObject (readonly)

The flags of the PO entry



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

def flags
  @flags
end

#msgidObject (readonly)

The msgid content



7
8
9
# File 'lib/rdoc/generator/pot/po_entry.rb', line 7

def msgid
  @msgid
end

#msgstrObject (readonly)

The msgstr content



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

def msgstr
  @msgstr
end

#referencesObject (readonly)

The locations where the PO entry is extracted



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

def references
  @references
end

#translator_commentObject (readonly)

The comment content created by translator (PO editor)



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

def translator_comment
  @translator_comment
end

Instance Method Details

#merge(other_entry) ⇒ Object

Merges the PO entry with other_entry.



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/rdoc/generator/pot/po_entry.rb', line 55

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_sObject

Returns the PO entry in PO format.



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rdoc/generator/pot/po_entry.rb', line 40

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