Class: Nele::GenericTranslator
- Inherits:
-
Object
- Object
- Nele::GenericTranslator
show all
- Defined in:
- lib/nele/generic_translator.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of GenericTranslator.
10
11
12
|
# File 'lib/nele/generic_translator.rb', line 10
def initialize
validate_children()
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
4
5
6
|
# File 'lib/nele/generic_translator.rb', line 4
def config
@config
end
|
#uri ⇒ Object
Returns the value of attribute uri.
3
4
5
|
# File 'lib/nele/generic_translator.rb', line 3
def uri
@uri
end
|
Class Method Details
.build_translator_class_name(name) ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/nele/generic_translator.rb', line 30
def build_translator_class_name(name)
klass_name = name.to_s.capitalize + "Translator"
begin
Nele.const_get(klass_name)
rescue NameError
raise(::Nele::TranslatorInvalidError, "invalid translator")
end
end
|
.check_inheritance(klass) ⇒ Object
Instance Method Details
#name ⇒ Object
18
19
20
21
|
# File 'lib/nele/generic_translator.rb', line 18
def name
klass_name = self.class.to_s.split("::")[1]
@name ||= klass_name.split('Translator')[0].downcase
end
|
#parse_uri(uri) ⇒ Object
14
15
16
|
# File 'lib/nele/generic_translator.rb', line 14
def parse_uri(uri)
URI.parse(uri.gsub(" ", "+"))
end
|
#translate(str) ⇒ Object
23
24
25
26
27
|
# File 'lib/nele/generic_translator.rb', line 23
def translate(str)
build_request(str)
res = connect()
parse_response(res)
end
|