Class: YamlTranslator::Translator

Inherits:
Object
  • Object
show all
Defined in:
lib/yaml-translator/translator.rb

Instance Method Summary collapse

Constructor Details

#initialize(adapter = Adapters::NoopAdaptor.new) ⇒ Translator

Returns a new instance of Translator.



5
6
7
8
# File 'lib/yaml-translator/translator.rb', line 5

def initialize(adapter = Adapters::NoopAdaptor.new)
  @path = KeyPath.new
  @adapter = adapter
end

Instance Method Details

#translate(values, options = {}) ⇒ Hash

Translate target

Parameters:

  • values (Hash)

    Hash of translate target

Returns:

  • (Hash)

    translated hash



14
15
16
# File 'lib/yaml-translator/translator.rb', line 14

def translate(values, options={})
  TranslatedResult.new(rebuild(translate_tree(flatten(values), options)), options[:to])
end