class Prez::Assets::Image

Public Instance Methods

close() click to toggle source
# File lib/prez/assets.rb, line 86
def close
  %{" />}
end
compile(contents) click to toggle source
# File lib/prez/assets.rb, line 109
def compile(contents)
  Prez::DataUri.new(image_type, contents).to_s
end
extension() click to toggle source
# File lib/prez/assets.rb, line 60
def extension
  "image"
end
image_type() click to toggle source
# File lib/prez/assets.rb, line 90
def image_type
  extension = file[/\.([^.]*)$/, 1]

  case extension
  when "gif"
    "image/gif"
  when "jpeg", "jpg"
    "image/jpeg"
  when "png"
    "image/png"
  when "svg"
    "image/svg+xml"
  when "tif", "tiff"
    "image/tiff"
  else
    raise Prez::Error.new("Unknown image extension '#{extension}'")
  end
end
open() click to toggle source
# File lib/prez/assets.rb, line 64
def open
  attributes = []

  if options[:width]
    attributes << %{width="#{options[:width]}"}
  end

  if options[:height]
    attributes << %{height="#{options[:height]}"}
  end

  if options[:id]
    attributes << %{id="#{options[:id]}"}
  end

  if options[:style]
    attributes << %{style="#{options[:style]}"}
  end

  %{<img #{attributes.join " "} src="}
end
self_closing?() click to toggle source
# File lib/prez/assets.rb, line 56
def self_closing?
  true
end