Class: Crowsad::Learn_Present_Actions

Inherits:
Object
  • Object
show all
Defined in:
lib/crowsad.rb

Class Method Summary collapse

Class Method Details

.teach_wordObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/crowsad.rb', line 32

def self.teach_word
  require "duck_duck_go"
  
  old_present_action = File.read("dictionary/present_action.txt")
  
  new_word = File.read("data/input/present_action.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/present_action.txt', 'w') { |f|
    f.puts zci.heading
    
    f.puts old_present_action
  }
end