class Mirador::Formatter

Constants

DATA_URI_RXP

Public Instance Methods

buffer(item) click to toggle source
# File lib/mirador/formatter.rb, line 71
def buffer item
  encode_filedata(item)
end
data_uri(item) click to toggle source
# File lib/mirador/formatter.rb, line 89
def data_uri item
  item.sub(DATA_URI_RXP, '').gsub(/\n/,'')
end
encoded_string(item) click to toggle source
# File lib/mirador/formatter.rb, line 85
def encoded_string item
  item.gsub(/\n/, '')
end
file(item) click to toggle source
# File lib/mirador/formatter.rb, line 75
def file item
  encode_filedata(
    if item.respond_to? :read
      item.read
    else
      File.read(item)
    end
  )
end
url(item) click to toggle source
# File lib/mirador/formatter.rb, line 67
def url item
  item
end

Private Instance Methods

encode_filedata(data) click to toggle source
# File lib/mirador/formatter.rb, line 95
def encode_filedata(data)
  Base64.encode64(data).gsub(/\n/, '')
end