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.


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

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


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

def extracted_comment
  @extracted_comment
end

#flagsObject (readonly)

The flags of the PO entry


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

def flags
  @flags
end

#msgidObject (readonly)

The msgid content


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

def msgid
  @msgid
end

#msgstrObject (readonly)

The msgstr content


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

def msgstr
  @msgstr
end

#referencesObject (readonly)

The locations where the PO entry is extracted


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

def references
  @references
end

#translator_commentObject (readonly)

The comment content created by translator (PO editor)


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

def translator_comment
  @translator_comment
end

Instance Method Details

#merge(other_entry) ⇒ Object

Merges the PO entry with other_entry.


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

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.


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

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