Module: LoremImageWare::Helpers
- Defined in:
- lib/lorem-image-ware.rb
Instance Method Summary collapse
- #default_lorem_image_height ⇒ Object
- #default_lorem_image_width ⇒ Object
- #lorem_image_path(options = {}) ⇒ Object
- #lorem_image_root ⇒ Object
- #lorem_image_tag(options = {}) ⇒ Object
Instance Method Details
#default_lorem_image_height ⇒ Object
28 29 30 |
# File 'lib/lorem-image-ware.rb', line 28 def default_lorem_image_height 200 end |
#default_lorem_image_width ⇒ Object
32 33 34 |
# File 'lib/lorem-image-ware.rb', line 32 def default_lorem_image_width 400 end |
#lorem_image_path(options = {}) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/lorem-image-ware.rb', line 36 def lorem_image_path( = {}) height = .fetch(:height, default_lorem_image_height) width = .fetch(:width, default_lorem_image_width) type = .fetch(:type, "abstract") "#{lorem_image_root}/image/#{width}/#{height}/#{type}?r=#{rand(99)}" end |
#lorem_image_root ⇒ Object
24 25 26 |
# File 'lib/lorem-image-ware.rb', line 24 def lorem_image_root "/lorem" end |
#lorem_image_tag(options = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/lorem-image-ware.rb', line 44 def lorem_image_tag( = {}) height = .fetch(:height, default_lorem_image_height) width = .fetch(:width, default_lorem_image_width) html_class = [[:class], "lorem-image"].compact.join(" ") html = %Q{<img src="#{lorem_image_path()}"} html += %Q{ class="#{html_class}" width="#{width}" height="#{height}"} html += %Q{ style="height: #{height}px; width: #{width}px;" />} end |