Class: Arxiv::Downloader::Bibtex
- Inherits:
-
Object
- Object
- Arxiv::Downloader::Bibtex
- Defined in:
- lib/arxiv/downloader/bibtex.rb
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(metadata, client: nil) ⇒ Bibtex
constructor
A new instance of Bibtex.
- #key ⇒ Object
- #synthesize ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(metadata, client: nil) ⇒ Bibtex
Returns a new instance of Bibtex.
4 5 6 7 |
# File 'lib/arxiv/downloader/bibtex.rb', line 4 def initialize , client: nil @metadata = @client = client end |
Instance Method Details
#fetch ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/arxiv/downloader/bibtex.rb', line 23 def fetch return nil if @client.nil? response = @client.get url return nil unless response.status.success? response.to_s end |
#key ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/arxiv/downloader/bibtex.rb', line 36 def key last_name = @metadata..first.split.last.downcase.gsub(/[^a-z]/, '') year = @metadata.published.year title_word = Slug.new(@metadata.title).to_s.split('-').first "#{last_name}#{year}#{title_word}" end |
#synthesize ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/arxiv/downloader/bibtex.rb', line 9 def synthesize <<~BIBTEX @misc{#{key}, title={#{@metadata.title}}, author={#{}}, year={#{@metadata.published.year}}, eprint={#{@metadata.arxiv_id}}, archivePrefix={arXiv}, primaryClass={#{@metadata.primary_category[:id]}}, url={#{@metadata.arxiv_url}}, } BIBTEX end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/arxiv/downloader/bibtex.rb', line 32 def to_s fetch || synthesize end |