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
10 11 12 |
# File 'lib/puttext/po_file.rb', line 10 def initialize(entries) @entries = entries end |
Instance Attribute Details
#entries ⇒ Object
Returns the value of attribute entries.
5 6 7 |
# File 'lib/puttext/po_file.rb', line 5 def entries @entries end |
Instance Method Details
#==(other) ⇒ Object
31 32 33 |
# File 'lib/puttext/po_file.rb', line 31 def ==(other) @entries.sort == other.entries.sort end |
#to_s ⇒ Object
14 15 16 17 18 |
# File 'lib/puttext/po_file.rb', line 14 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.
22 23 24 25 26 27 28 29 |
# File 'lib/puttext/po_file.rb', line 22 def write_to(io) deduplicate @entries.each_with_index do |entry, index| io.write("\n") unless index == 0 io.write(entry.to_s) end end |