Class: Typekit::Processing::Translator

Inherits:
Object
  • Object
show all
Defined in:
lib/typekit/processing/translator.rb

Instance Method Summary collapse

Constructor Details

#initialize(format:) ⇒ Translator

Returns a new instance of Translator.



4
5
6
# File 'lib/typekit/processing/translator.rb', line 4

def initialize(format:)
  @parser = Parser.build(format)
end

Instance Method Details

#process(response) ⇒ Object



8
9
10
11
12
13
# File 'lib/typekit/processing/translator.rb', line 8

def process(response)
  data = @parser.process(response.body) rescue nil
  data = { nil => nil } unless data.is_a?(Hash) && data.length == 1
  name, object = *data.first
  Converter.build(name).process(response, object)
end