class Crowsad::Learn_Third_Object

Public Class Methods

teach_word() click to toggle source
# File lib/crowsad.rb, line 107
def self.teach_word
  require "duck_duck_go"
  
  old_third_object = File.read("dictionary/third_object.txt")

  new_word = File.read("data/input/third_object.txt").strip

  ddg = DuckDuckGo.new
  zci = ddg.zeroclickinfo(new_word)

  open("data/output/glossary/#{new_word}.txt", 'w') { |f|
    f.puts zci.heading
    f.puts zci.abstract_text
    f.puts zci.related_topics['_'][0].text
  }
  
  open('dictionary/next_action.txt', 'w') { |f|
    f.puts zci.heading
    
    f.puts old_third_object
  }
end