Class: PutText::POFile
- Inherits:
-
Object
- Object
- PutText::POFile
- Defined in:
- lib/puttext/po_file.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
Returns the value of attribute entries.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(entries) ⇒ POFile
constructor
Create a new POFile.
- #to_s ⇒ Object
-
#write_to(io) ⇒ Object
Write the contents of this file to the specified IO object.
Constructor Details
#initialize(entries) ⇒ POFile
Create a new POFile
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/puttext/po_file.rb', line 13 def initialize(entries) @entries = entries now = Time.now.strftime('%Y-%m-%d %H:%M%z') @header_entry = POEntry.new( flags: ['fuzzy'], msgid: '', msgstr: " POT-Creation-Date: \#{now}\n MIME-Version: 1.0\n Content-Type: text/plain; charset=UTF-8\n STRING\n )\nend\n".unindent |
Instance Attribute Details
#entries ⇒ Object
Returns the value of attribute entries.
8 9 10 |
# File 'lib/puttext/po_file.rb', line 8 def entries @entries end |
Instance Method Details
#==(other) ⇒ Object
48 49 50 |
# File 'lib/puttext/po_file.rb', line 48 def ==(other) @entries.sort == other.entries.sort end |
#to_s ⇒ Object
29 30 31 32 33 |
# File 'lib/puttext/po_file.rb', line 29 def to_s str_io = StringIO.new write_to(str_io) str_io.string end |
#write_to(io) ⇒ Object
Write the contents of this file to the specified IO object.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/puttext/po_file.rb', line 37 def write_to(io) deduplicate io.write(@header_entry.to_s) @entries.each do |entry| io.write("\n") io.write(entry.to_s) end end |