Class: Translatomatic::ResourceFile::Subtitle
- Defined in:
- lib/translatomatic/resource_file/subtitle.rb
Overview
Subtitle resource file. requires ‘titlekit’ gem
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.enabled? ⇒ boolean
True if this resource format is enabled.
-
.extensions ⇒ Array<String>
File extensions supported by this resource file.
Instance Method Summary collapse
-
#save(target = path, options = {}) ⇒ void
Save the resource file.
-
#set(key, value) ⇒ String
Set a property.
Methods inherited from Base
#create_variable, #get, #get_context, #initialize, key_value?, #locale_path, preferred_locale_separator, #properties, #properties=, #sentences, supports_variable_interpolation?, #to_s, #type, #variable_regex
Methods included from PathUtils
#detect_path_locale, #modify_path_locale
Constructor Details
This class inherits a constructor from Translatomatic::ResourceFile::Base
Class Method Details
.enabled? ⇒ boolean
Returns True if this resource format is enabled.
12 13 14 15 16 17 18 19 |
# File 'lib/translatomatic/resource_file/subtitle.rb', line 12 def self.enabled? @enabled ||= begin require 'titlekit' true rescue LoadError false end end |
.extensions ⇒ Array<String>
Returns File extensions supported by this resource file.
7 8 9 |
# File 'lib/translatomatic/resource_file/subtitle.rb', line 7 def self.extensions %w[srt ass ssa] end |
Instance Method Details
#save(target = path, options = {}) ⇒ void
This method returns an undefined value.
Save the resource file.
33 34 35 36 |
# File 'lib/translatomatic/resource_file/subtitle.rb', line 33 def save(target = path, = {}) add_created_by unless [:no_created_by] || created_by? export(target) end |
#set(key, value) ⇒ String
Set a property
22 23 24 25 26 27 28 29 30 |
# File 'lib/translatomatic/resource_file/subtitle.rb', line 22 def set(key, value) super(key, value) if @subtitle_map.include?(key) @subtitle_map[key][:lines] = value.to_s else add_subtitle(lines: value) unless value.blank? end end |