Class: Translatomatic::ResourceFile::XML
- Defined in:
- lib/translatomatic/resource_file/xml.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.
-
#set(key, value) ⇒ String
Set a property.
Methods inherited from Base
#format, #get, #locale_path, #sentences, #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/xml.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/xml.rb', line 5 def self.extensions %w{xml} end |
Instance Method Details
#save(target = path, options = {}) ⇒ void
This method returns an undefined value.
Save the resource file.
23 24 25 26 27 28 |
# File 'lib/translatomatic/resource_file/xml.rb', line 23 def save(target = path, = {}) if @doc add_created_by unless [:no_created_by] target.write(@doc.to_xml) end end |
#set(key, value) ⇒ String
Set a property
17 18 19 20 |
# File 'lib/translatomatic/resource_file/xml.rb', line 17 def set(key, value) super(key, value) @nodemap[key].content = value if @nodemap.include?(key) end |