Sha256: b02765bf5ae1f5bc6bf934a5e69bcef1349c24c7be2e70e6278f993e4194e071

Contents?: true

Size: 684 Bytes

Versions: 1

Compression:

Stored size: 684 Bytes

Contents

require "rubygems"
require "open-uri"
require "nokogiri"
require 'terminal-table'

require "bilisim_sozlugu/version"

module BilisimSozlugu
  URL = "http://www.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 == "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-0.0.2 lib/bilisim_sozlugu.rb