class Lang
Attributes
code[R]
mistakes[R]
Public Class Methods
new(code = 'en')
click to toggle source
# File lib/asker/lang/lang.rb, line 14 def initialize(code = 'en') @code = code.to_s load_files end
Public Instance Methods
lang()
click to toggle source
# File lib/asker/lang/lang.rb, line 19 def lang @code end
Private Instance Methods
load_files()
click to toggle source
# File lib/asker/lang/lang.rb, line 25 def load_files dirbase = File.join(File.dirname(__FILE__), '..', 'files', 'language') filepath = File.join(dirbase, @code, 'templates.yaml') @templates = load_yaml_file(filepath) filepath = File.join(dirbase, @code, 'connectors.yaml') @connectors = load_yaml_file(filepath) filepath = File.join(dirbase, @code, 'mistakes.yaml') @mistakes = load_yaml_file(filepath) end
load_yaml_file(filepath)
click to toggle source
rubocop:disable Security/YAMLLoad
# File lib/asker/lang/lang.rb, line 36 def load_yaml_file(filepath) begin content = YAML.load(File.new(filepath)) rescue StandardError => e Logger.verboseln '[ERROR] Lang.initialize():' \ " Reading YAML file <#{filepath}>" Logger.verboseln '[ADVISE] Revise apostrophe into string without \ symbol' raise e end content end