Class: Arxiv::Manuscript
- Inherits:
-
Object
- Object
- Arxiv::Manuscript
- Includes:
- HappyMapper
- Defined in:
- lib/arxiv/models/manuscript.rb
Instance Method Summary collapse
- #arxiv_id ⇒ Object
- #arxiv_versioned_id ⇒ Object
- #available_in_pdf? ⇒ Boolean
- #content_types ⇒ Object
- #legacy_article? ⇒ Boolean
- #pdf_url ⇒ Object
- #revision? ⇒ Boolean
- #version ⇒ Object
Instance Method Details
#arxiv_id ⇒ Object
27 28 29 |
# File 'lib/arxiv/models/manuscript.rb', line 27 def arxiv_id arxiv_versioned_id.match(/([^v]+)v\d+$/)[1] end |
#arxiv_versioned_id ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/arxiv/models/manuscript.rb', line 31 def arxiv_versioned_id if legacy_article? arxiv_url.match(/(#{Arxiv::LEGACY_URL_FORMAT})/)[1] else arxiv_url.match(/(#{Arxiv::CURRENT_URL_FORMAT})/)[1] end end |
#available_in_pdf? ⇒ Boolean
47 48 49 |
# File 'lib/arxiv/models/manuscript.rb', line 47 def available_in_pdf? content_types.any? { |type| type == "application/pdf" } end |
#content_types ⇒ Object
43 44 45 |
# File 'lib/arxiv/models/manuscript.rb', line 43 def content_types links.map(&:content_type).compact.delete_if { |t| t =~ /^\s*$/ } end |
#legacy_article? ⇒ Boolean
23 24 25 |
# File 'lib/arxiv/models/manuscript.rb', line 23 def legacy_article? arxiv_url =~ Arxiv::LEGACY_URL_FORMAT end |
#pdf_url ⇒ Object
51 52 53 54 55 56 |
# File 'lib/arxiv/models/manuscript.rb', line 51 def pdf_url if available_in_pdf? url = links.find { |l| l.content_type == "application/pdf" }.url StringScrubber.force_ssl_url(url) end end |
#revision? ⇒ Boolean
19 20 21 |
# File 'lib/arxiv/models/manuscript.rb', line 19 def revision? created_at != updated_at end |
#version ⇒ Object
39 40 41 |
# File 'lib/arxiv/models/manuscript.rb', line 39 def version arxiv_url.match(/v(\d+)$/)[1].to_i end |