class ChupaText::InputData
Public Class Methods
new(uri, options={})
click to toggle source
Calls superclass method
ChupaText::Data::new
# 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
Public Instance Methods
body()
click to toggle source
# File lib/chupa-text/input-data.rb, line 35 def body @content.body end
open(&block)
click to toggle source
# File lib/chupa-text/input-data.rb, line 47 def open(&block) @content.open(&block) end
peek_body(size)
click to toggle source
# File lib/chupa-text/input-data.rb, line 39 def peek_body(size) @content.peek_body(size) end
release()
click to toggle source
# File lib/chupa-text/input-data.rb, line 51 def release @content.release end
size()
click to toggle source
# File lib/chupa-text/input-data.rb, line 43 def size @content.size end
Private Instance Methods
download()
click to toggle 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