Class: Yuzu::Translators::Translator
- Inherits:
-
Register
- Object
- Register
- Yuzu::Translators::Translator
show all
- Defined in:
- lib/yuzu/translators/base.rb
Constant Summary
collapse
- @@translators =
{}
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.can_translate?(website_file) ⇒ Boolean
24
25
26
27
28
29
30
|
# File 'lib/yuzu/translators/base.rb', line 24
def self.can_translate?(website_file)
source_extension = website_file.path.extension
filetype = identify_filetype(source_extension)
not filetype.nil?
end
|
.identify_filetype(file_extension) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/yuzu/translators/base.rb', line 32
def self.identify_filetype(file_extension)
Translator.translators.each_pair do |filetype, translator|
return filetype if translator.translates?(file_extension)
end
return nil
end
|
8
9
10
|
# File 'lib/yuzu/translators/base.rb', line 8
def self.registry
:translators
end
|
.translate(contents, file_extension) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/yuzu/translators/base.rb', line 15
def self.translate(contents, file_extension)
filetype = identify_filetype(file_extension)
if not filetype.nil?
Translator.translators[filetype].translate(contents)
else
contents
end
end
|
.translators ⇒ Object
11
12
13
|
# File 'lib/yuzu/translators/base.rb', line 11
def self.translators
@@translators
end
|
Instance Method Details
#extensions ⇒ Object
47
48
49
|
# File 'lib/yuzu/translators/base.rb', line 47
def extensions
[]
end
|
#translate(contents) ⇒ Object
51
52
53
|
# File 'lib/yuzu/translators/base.rb', line 51
def translate(contents)
contents
end
|
#translates?(file_extension) ⇒ Boolean
43
44
45
|
# File 'lib/yuzu/translators/base.rb', line 43
def translates?(file_extension)
extensions.include?(file_extension)
end
|