Class: RDoc::Generator::POT::PO

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

Overview

Generates a PO format text

Instance Method Summary collapse

Constructor Details

#initializePO

Creates an object that represents PO format.



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

def initialize
  @entries = {}
  add_header
end

Instance Method Details

#add(entry) ⇒ Object

Adds a PO entry to the PO.



18
19
20
21
22
23
24
# File 'lib/rdoc/generator/pot/po.rb', line 18

def add entry
  existing_entry = @entries[entry.msgid]
  if existing_entry
    entry = existing_entry.merge(entry)
  end
  @entries[entry.msgid] = entry
end

#to_sObject

Returns PO format text for the PO.



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

def to_s
  po = ''
  sort_entries.each do |entry|
    po += "\n" unless po.empty?
    po += entry.to_s
  end
  po
end