class TransLaunder::ResponseParser
Public Class Methods
new(text)
click to toggle source
# File lib/translaunder/response_parser.rb, line 6 def initialize text @text = text end
Public Instance Methods
parse()
click to toggle source
# File lib/translaunder/response_parser.rb, line 10 def parse @text = decode @text extract_text end
Private Instance Methods
decode(text)
click to toggle source
# File lib/translaunder/response_parser.rb, line 17 def decode text encoding = 'UTF-8' text.gsub!(/(\\x26#39;)/, "'") text.force_encoding(encoding).encode(encoding) end
extract_text()
click to toggle source
# File lib/translaunder/response_parser.rb, line 23 def extract_text texts = @text.split("[[[")[1].sub!(/\]\].*/, ']').gsub!(/"/, '').split("],[") texts.map! do |t| t = t.split(",") t.first unless t.first.empty? end texts.join("") end