class Oversetter::Yandex::Getlangs

Lists supported translation 'directions,' pairs of source and target languages.

Public Instance Methods

get_lang(search, params) click to toggle source

@param search [String] The word or phrase for which to detect the language. @param params [Hash] The search parameters to use.

# File lib/oversetter/yandex/getlangs.rb, line 10
def get_lang(search, params)
        func, result = 'getLangs', nil
        lang = Oversetter::Yandex.new
        result = lang.get_word(search, func, params, result)
        result = MultiJson.load(result)
        dirs = result['dirs']
        if result['langs'] != nil
                langs = result['langs']
        end
        x, y, label = 0, dirs.length - 1, 'Translation directions'
        Oversetter.label(label)
        while x <= y
                print "#{dirs[x]}"
                print ', '
                x += 1
        end
        puts ''
        if langs != nil
                label = 'Language names'
                Oversetter.label(label)
                langs.map { |k,v|
                        print "#{k} -> #{v}"
                        print ', '
                }
                puts ''
        end
end