Class: ProgressBarHelper::ProgressBarCreator

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers, FormatHelper
Defined in:
app/helpers/progress_bar_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FormatHelper

#prepend_class, #squeeze_n_strip

Constructor Details

#initialize(options) ⇒ ProgressBarCreator

Returns a new instance of ProgressBarCreator.



10
11
12
# File 'app/helpers/progress_bar_helper.rb', line 10

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'app/helpers/progress_bar_helper.rb', line 7

def options
  @options
end

#output_bufferObject

Returns the value of attribute output_buffer.



8
9
10
# File 'app/helpers/progress_bar_helper.rb', line 8

def output_buffer
  @output_buffer
end

Instance Method Details

#renderObject



14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/progress_bar_helper.rb', line 14

def render
  percentage, label = process_progress_bar_options
  options[:style]   = "width: #{percentage}%"
  options[:role]    = 'progressbar'
  options[:aria]    = {valuemax: 100, valuemin: 0, valuenow: percentage}

   :div, options do
    label.present? ? label : ( :span, label, class: 'sr-only')
  end
end