Module: BilisimSozlugu
- Extended by:
- T::Sig
- Defined in:
- lib/bilisim_sozlugu/version.rb,
lib/bilisim_sozlugu.rb
Overview
typed: strict
Constant Summary collapse
- 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)
- VERSION =
"2.0.0"
Class Method Summary collapse
Class Method Details
.search(word) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bilisim_sozlugu.rb', line 16 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 |