Sha256: cb0ebcdb37acfa9be59c468ef7e0af214f9c433daefbeea013a92e35be41d4e5
Contents?: true
Size: 812 Bytes
Versions: 2
Compression:
Stored size: 812 Bytes
Contents
# typed: true require "rubygems" require "open-uri" require "nokogiri" require 'terminal-table' 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bilisim_sozlugu-2.0.1 | lib/bilisim_sozlugu.rb |
bilisim_sozlugu-2.0.0 | lib/bilisim_sozlugu.rb |