Class: DuckSum::Define_Words
- Inherits:
-
Object
- Object
- DuckSum::Define_Words
- Defined in:
- lib/duck_sum.rb
Class Method Summary collapse
-
.first_input ⇒ Object
Plant first word input seed.
-
.second_input ⇒ Object
Plant second word input seed.
-
.sum_of_both ⇒ Object
Create a QR code that’s the sum of both definitions.
Class Method Details
.first_input ⇒ Object
Plant first word input seed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/duck_sum.rb', line 9 def self.first_input require "duck_duck_go" require "rqrcode" word_search = File.read("data/input/first_input.txt").strip ddg = DuckDuckGo.new zci = ddg.zeroclickinfo(word_search) open("data/input/first_definition.txt", "w") { |f| f.puts zci.heading f.puts zci.abstract_text f.puts zci.["_"][0].text } zci_header = zci.heading zci_abstract = zci.abstract_text = zci. name = zci.heading qr_name = "#{zci_header}\n#{zci_abstract}" qrcode = RQRCode::QRCode.new(qr_name) # NOTE: showing with default options specified explicitly png = qrcode.as_png( bit_depth: 1, border_modules: 4, color_mode: ChunkyPNG::COLOR_GRAYSCALE, color: 'black', file: nil, fill: 'white', module_px_size: 6, resize_exactly_to: false, resize_gte_to: false, size: 480 ) IO.write("data/non_compound/#{name}.png", png.to_s) end |
.second_input ⇒ Object
Plant second word input seed.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/duck_sum.rb', line 52 def self.second_input require "duck_duck_go" require "rqrcode" word_search = File.read("data/input/second_input.txt").strip ddg = DuckDuckGo.new zci = ddg.zeroclickinfo(word_search) open("data/input/second_definition.txt", "w") { |f| f.puts zci.heading f.puts zci.abstract_text f.puts zci.["_"][0].text } zci_header = zci.heading zci_abstract = zci.abstract_text = zci. name = zci.heading qr_name = "#{zci_header}\n#{zci_abstract}" qrcode = RQRCode::QRCode.new(qr_name) # NOTE: showing with default options specified explicitly png = qrcode.as_png( bit_depth: 1, border_modules: 4, color_mode: ChunkyPNG::COLOR_GRAYSCALE, color: 'black', file: nil, fill: 'white', module_px_size: 6, resize_exactly_to: false, resize_gte_to: false, size: 480 ) IO.write("data/non_compound/#{name}.png", png.to_s) end |
.sum_of_both ⇒ Object
Create a QR code that’s the sum of both definitions.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/duck_sum.rb', line 95 def self.sum_of_both require "duck_duck_go" first_file = File.readlines("data/input/first_definition.txt") second_file = File.readlines("data/input/second_definition.txt") puts "\n\n" heading_1 = first_file[0].strip # Header text_abstract_1 = first_file[1].strip # Definition = first_file[2].strip # Related Topics heading_2 = second_file[0].strip # Header text_abstract_2 = second_file[1].strip # Definition = second_file[2].strip # Related Topics print "Your first look up is: #{text_abstract_1} #{related_topic_1}\nYour second look up is: #{text_abstract_2} #{related_topic_2}\n\n" new_lookup = "#{heading_1} #{heading_2}" puts new_lookup ddg = DuckDuckGo.new zci = ddg.zeroclickinfo(new_lookup) print "You must be looking for #{new_lookup}: ".strip puts zci.abstract_text compound_name = zci.heading zci_header = zci.heading zci_abstract = zci.abstract_text = zci. qr_name = "#{zci_header}\n#{zci_abstract}" qrcode = RQRCode::QRCode.new(qr_name) # NOTE: showing with default options specified explicitly png = qrcode.as_png( bit_depth: 1, border_modules: 4, color_mode: ChunkyPNG::COLOR_GRAYSCALE, color: 'black', file: nil, fill: 'white', module_px_size: 6, resize_exactly_to: false, resize_gte_to: false, size: 480 ) IO.write("data/compound/#{compound_name}.png", png.to_s) sleep(3) end |