class Archivist::Model::Document
Constants
- UnsupportedFormat
Attributes
conn[R]
Public Class Methods
new()
click to toggle source
# File lib/archivist/models/document.rb, line 23 def initialize @conn = DEFAULT_CONNECTION end
Public Instance Methods
download(format=:text)
click to toggle source
# File lib/archivist/models/document.rb, line 36 def download(format=:text) # e.g. format_index.text_format file_format = format_index.send(:"#{format}_format") if file_format.nil? raise UnsupportedFormat, "#{identifier} not available in format #{format}" else # e.g. /download/firstbooknapole00gruagoog/firstbooknapole00gruagoog_djvu.txt @conn.get(download_path(file_format.name)). body.force_encoding('UTF-8') end end
download_path(file)
click to toggle source
# File lib/archivist/models/document.rb, line 48 def download_path(file) "/download/#{identifier}/#{file}" end
format_index()
click to toggle source
# File lib/archivist/models/document.rb, line 27 def format_index response = @conn.get(index_xml_path) Model::FormatIndex.new.tap do |idx| rep = Representation::FormatIndex.new(idx) # binding.pry rep.from_xml(response.body) end end
index_xml_path()
click to toggle source
# File lib/archivist/models/document.rb, line 52 def index_xml_path download_path("#{identifier}_files.xml") end