Sha256: 1a484a3a2dbec21c6cef7da5d3b64dede663f0f3770eb107f7bc932de7c9020e
Contents?: true
Size: 837 Bytes
Versions: 1
Compression:
Stored size: 837 Bytes
Contents
# typed: true require "rubygems" require "open-uri" require "nokogiri" require 'terminal-table' require "sorbet-runtime" require "bilisim_sozlugu/version" module BilisimSozlugu extend T::Sig URL = T.let("http://eski.tbd.org.tr/index.php?sayfa=sozluk&mi1&tipi=ara&harf=A&arama=".freeze, String) CSS_SELECTOR = T.let("table tbody tr".freeze, String) sig {params(word: String).void} def self.search(word) call_url = T.let(URL + word, String) page = Nokogiri::HTML(open(call_url)) rows = page.css(CSS_SELECTOR) if rows.last.text.match("Aranan Kelime") puts "Aradığınız kelime bulunamadı." else words = rows.map { |row| [row.children.first.children.text, row.children.last.text] } table = Terminal::Table.new :rows => words.drop(2) puts table end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bilisim_sozlugu-2.0.2 | lib/bilisim_sozlugu.rb |