Module: ProgressBarSnapshotHelper

Defined in:
lib/progress_bar_snapshot_helper.rb

Overview

need a controler action to actually do the image generation and sending of the image blob. See README for examples.

Instance Method Summary collapse

Instance Method Details

#progress_bar_png_tag(percent, opts = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/progress_bar_snapshot_helper.rb', line 8

def progress_bar_png_tag(percent, opts = {})
  url = { 
    :percentage => percent 
  }

  options = url.merge(opts)

  # extra html attributes for the image tag
  attributes = %(class="#{options[:class] || 'progressbar'}" alt="#{percent.round}%" )
  attributes << %(title="#{options[:title]}" ) if options[:title]

  %(<img src="#{ url_for options }" #{attributes}/>)
end