Module: LoremImageWare::Helpers

Defined in:
lib/lorem-image-ware.rb

Instance Method Summary collapse

Instance Method Details

#lorem_image_path(options = {}) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/lorem-image-ware.rb', line 24

def lorem_image_path(options = {})
  height = options.fetch(:height, 200)
  width  = options.fetch(:width, 400)
  tag    = options.fetch(:tag, "abstract")

  "#{lorem_image_root}/image/#{width}/#{height}/#{tag}?r=#{rand(99)}"
end

#lorem_image_rootObject



20
21
22
# File 'lib/lorem-image-ware.rb', line 20

def lorem_image_root
  "/lorem"
end

#lorem_image_tag(options = {}) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/lorem-image-ware.rb', line 32

def lorem_image_tag(options = {})
  height     = options.fetch(:height, 200)
  width      = options.fetch(:width, 400)
  html_class = [options[:class], "lorem-image"].compact.join(" ")

  %Q{<img src="#{lorem_image_path(options)}" class="#{html_class}" width="#{width}" height="#{height}" style="height: #{height}px; width: #{width}px;" />}
end