Sha256: 276157291c96ee2fbf4a3ff5a98f3357c886c2181f313c43f26bae737d133401

Contents?: true

Size: 701 Bytes

Versions: 4

Compression:

Stored size: 701 Bytes

Contents

require "rubygems"
require "open-uri"
require "nokogiri"
require 'terminal-table'
require "bilisim_sozlugu/version"

module BilisimSozlugu
  URL          = "http://eski.tbd.org.tr/index.php?sayfa=sozluk&mi1&tipi=ara&harf=A&arama=".freeze
  CSS_SELECTOR = "table tbody tr".freeze

  def self.search(word)
    call_url = URL + word
    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

4 entries across 4 versions & 1 rubygems

Version Path
bilisim_sozlugu-1.3.0 lib/bilisim_sozlugu.rb
bilisim_sozlugu-1.2.0 lib/bilisim_sozlugu.rb
bilisim_sozlugu-1.1.0 lib/bilisim_sozlugu.rb
bilisim_sozlugu-1.0.0 lib/bilisim_sozlugu.rb