Class: Translatomatic::ResourceFile::Text
- Defined in:
- lib/translatomatic/resource_file/text.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.extensions ⇒ Array<String>
File extensions supported by this resource file.
Instance Method Summary collapse
-
#initialize(path, locale = nil) ⇒ Translatomatic::ResourceFile::Base
constructor
Create a new resource file.
-
#save(target = path, options = {}) ⇒ void
Save the resource file.
Methods inherited from Base
#format, #get, #locale_path, #sentences, #set, #to_s, #valid?
Methods included from Util
Constructor Details
#initialize(path, locale = nil) ⇒ Translatomatic::ResourceFile::Base
Create a new resource file. If locale is unspecified, attempts to determine the locale of the file automatically, and if that fails, uses the default locale.
10 11 12 13 14 |
# File 'lib/translatomatic/resource_file/text.rb', line 10 def initialize(path, locale = nil) super(path, locale) @valid = true @properties = @path.exist? ? read(@path) : {} end |
Class Method Details
.extensions ⇒ Array<String>
Returns File extensions supported by this resource file.
5 6 7 |
# File 'lib/translatomatic/resource_file/text.rb', line 5 def self.extensions %w{txt text} end |
Instance Method Details
#save(target = path, options = {}) ⇒ void
This method returns an undefined value.
Save the resource file.
17 18 19 20 |
# File 'lib/translatomatic/resource_file/text.rb', line 17 def save(target = path, = {}) values = @properties.values.collect { |i| i.strip + "\n" } target.write(values.join) end |