Class: MgnetMe::Short
- Inherits:
-
Object
- Object
- MgnetMe::Short
- Defined in:
- lib/mgnetme/short.rb
Class Method Summary collapse
Class Method Details
.please(magnet_long) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mgnetme/short.rb', line 7 def self.please(magnet_long) magnet_long = URI.escape(magnet_long) doc = Nokogiri::XML(open('http://mgnet.me/api/create/?m=' + magnet_long + '&format=xml')) state = doc.xpath('//state').text shorturl = doc.xpath('//shorturl').text = doc.xpath('//message').text raise if state == "failure" shorturl end |