Skip to content

Instantly share code, notes, and snippets.

@vmanyushin
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vmanyushin/5c04002d0309e0554af0 to your computer and use it in GitHub Desktop.
Save vmanyushin/5c04002d0309e0554af0 to your computer and use it in GitHub Desktop.
Склонятор на ruby
#!/usr/bin/env ruby
require 'uri'
require 'open-uri'
require 'nokogiri'
uri = URI.parse('http://export.yandex.ru/inflect.xml')
params = { :name => "#{ARGV[0]}" }
uri.query = URI.encode_www_form( params )
doc = Nokogiri::HTML(uri.open.read)
puts doc.xpath("//inflection[contains(@case,#{ARGV[1] || 4})]").first.content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment