Module: Y_Speller

Defined in:
lib/y_speller.rb

Constant Summary collapse

BASE_URL =
"http://speller.yandex.net/services/spellservice.json/checkText"

Class Method Summary collapse

Class Method Details

.check(string, lang = nil) ⇒ Object



14
15
16
17
18
19
# File 'lib/y_speller.rb', line 14

def self.check string, lang = nil
  p "Строка для проверки: #{string}"
  response = HTTPClient.new.get_query(BASE_URL, {text: string, lang: lang} )
  result = JSON.parse(response.body)
  result
end

.inputObject



8
9
10
11
12
# File 'lib/y_speller.rb', line 8

def self.input
  p "Введите строку для проверки:"
  gets.chomp

end


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/y_speller.rb', line 21

def self.print_result result
  if result.empty?
    puts "Ошибок не найдено"
  else
    result.each { |row|
      puts "Найдена ошибка в слове #{row["word"]}"
    }

  end

end