class Translator::ConfigFile
Attributes
from[R]
to[R]
Public Class Methods
default_from()
click to toggle source
# File lib/translator/config_file.rb, line 38 def default_from get_default_config[:from] end
default_to()
click to toggle source
# File lib/translator/config_file.rb, line 34 def default_to get_default_config[:to] end
exist?()
click to toggle source
# File lib/translator/config_file.rb, line 42 def exist? File.exist?("#{Dir.home}/.translator") end
get_default_config()
click to toggle source
# File lib/translator/config_file.rb, line 25 def get_default_config config = [] File.open("#{Dir.home}/.translator").each_line do |l| config << l.delete("\n") end { from: config[0], to: config[1] } end
new(from, to)
click to toggle source
# File lib/translator/config_file.rb, line 5 def initialize(from, to) from = 'auto' if from.empty? raise ArgumentError, 'Precisa passar qual idioma deseja traduzir' if to.empty? @from = from.downcase @to = to.downcase end
Public Instance Methods
config_file_path()
click to toggle source
# File lib/translator/config_file.rb, line 13 def config_file_path "#{Dir.home}/.translator" end
save_config()
click to toggle source
# File lib/translator/config_file.rb, line 17 def save_config File.open(config_file_path, 'w') do |f| f.write("#{from}\n#{to}\n") f.close end end