class ChupaText::InputData
Public Class Methods
Source
# File lib/chupa-text/input-data.rb, line 23 def initialize(uri, options={}) super(options) self.uri = uri case @uri when URI::HTTP, URI::FTP @content = download self.path = @content.path else @content = FileContent.new(path) end end
Calls superclass method
ChupaText::Data::new
Public Instance Methods
Source
# File lib/chupa-text/input-data.rb, line 47 def open(&block) @content.open(&block) end
Source
# File lib/chupa-text/input-data.rb, line 39 def peek_body(size) @content.peek_body(size) end
Private Instance Methods
Source
# File lib/chupa-text/input-data.rb, line 56 def download begin @uri.open("rb") do |input| self.mime_type = input.content_type.split(/;/).first VirtualContent.new(input, @uri.path) end rescue OpenURI::HTTPError => error raise DownloadError.new(@uri, error.message.strip) rescue => error raise DownloadError.new(@uri, "#{error.class}: #{error.message}") end end