Sha256: c07172254411558ec7b61ef4efd26832801542639d670521e7bfbc6064854013
Contents?: true
Size: 577 Bytes
Versions: 13
Compression:
Stored size: 577 Bytes
Contents
#encoding: UTF-8 require 'json' module Termit class TextResponseHandler include CanOutput delegate :display_translation, to: :output_manager def initialize text @text = decode text end def call translation = extract_translation display_translation translation translation end private def extract_translation JSON.parse(@text)["items"][0]["text"] end def decode text encoding = 'UTF-8' text.gsub!(/(\\x26#39;)/, "'") text.force_encoding(encoding).encode(encoding) end end end
Version data entries
13 entries across 13 versions & 1 rubygems