Class: Arxiv::Manuscript

Inherits:
Object
  • Object
show all
Includes:
HappyMapper
Defined in:
lib/arxiv/models/manuscript.rb

Instance Method Summary collapse

Instance Method Details

#arxiv_idObject



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_idObject



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

Returns:

  • (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_typesObject



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

Returns:

  • (Boolean)


23
24
25
# File 'lib/arxiv/models/manuscript.rb', line 23

def legacy_article?
  arxiv_url =~ Arxiv::LEGACY_URL_FORMAT
end

#pdf_urlObject



51
52
53
54
55
56
57
# 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
    url = StringScrubber.force_ssl_url(url)
    "#{url}.pdf" unless url =~ /\.pdf$/
  end
end

#revision?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/arxiv/models/manuscript.rb', line 19

def revision?
  created_at != updated_at
end

#versionObject



39
40
41
# File 'lib/arxiv/models/manuscript.rb', line 39

def version
  arxiv_url.match(/v(\d+)$/)[1].to_i
end