class ArxivApi
Constants
- BASE_URL
Attributes
abstruct[R]
pdfurl[R]
references[RW]
title[R]
Public Class Methods
new(id)
click to toggle source
# File lib/arxiv/references/ArxivApi.rb, line 9 def initialize(id) id = "#{BASE_URL}/abs/#{id}" if id.index('http').nil? charset = nil html = open(id) do |f| charset = f.charset f.read end @page = Nokogiri::HTML.parse(html, nil, charset) @title = fetch_title @authors = fetch_authors @abstruct = fetch_abstruct @pdfurl = fetch_pdfurl @references = nil end
Public Instance Methods
fetch_abstruct()
click to toggle source
# File lib/arxiv/references/ArxivApi.rb, line 32 def fetch_abstruct @page.xpath('//*[@id="abs"]/div[2]/blockquote').children.select{|i| i.name = 'text'}.reverse.shift.text end
fetch_pdfurl()
click to toggle source
# File lib/arxiv/references/ArxivApi.rb, line 36 def fetch_pdfurl "#{BASE_URL}#{@page.xpath('//*[@id="abs"]/div[1]/div[1]/ul/li[1]/a').attr('href').value}" end
fetch_title()
click to toggle source
# File lib/arxiv/references/ArxivApi.rb, line 24 def fetch_title @page.xpath('//*[@id="abs"]/div[2]/h1').children.select{|i| i.name=='text'}.shift.text.gsub(/\n/,'') end
to_json()
click to toggle source
# File lib/arxiv/references/ArxivApi.rb, line 40 def to_json JSON.pretty_generate({title: @title, authors: @authors, abstruct: @abstruct, pdfurl: @pdfurl, references: @references}) end