Module: BootstrapProgressbar::Helper::Private
- Included in:
- BootstrapProgressbar::Helper
- Defined in:
- lib/bootstrap_progressbar/helper.rb
Class Method Summary collapse
- .check_percent(percent) ⇒ Object
-
.only_progress_bar(percent, options = {}) ⇒ Object
- Params:
percent
Fixnum
between 0 to 1.00options
-
alternative: [‘success’, ‘danger’, ‘warning’, ‘info’] striped: boolean active: boolean label: boolean class: a string contained more given class.
- Params:
Class Method Details
.check_percent(percent) ⇒ Object
5 6 7 8 9 |
# File 'lib/bootstrap_progressbar/helper.rb', line 5 def self.check_percent(percent) if percent < 0 || percent > 1 throw ArgumentError.new('the percent(first argument) should between 0 to 1') end end |
.only_progress_bar(percent, options = {}) ⇒ Object
Params:
percent
-
Fixnum
between 0 to 1.00 options
-
alternative: [‘success’, ‘danger’, ‘warning’, ‘info’] striped: boolean active: boolean label: boolean class: a string contained more given class
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/bootstrap_progressbar/helper.rb', line 19 def self.(percent, = {}) percent *= 100 percent = percent.to_i case [:alternative] when 'success' alternative = 'progress-bar-success' when 'danger' alternative = 'progress-bar-danger' when 'warning' alternative = 'progress-bar-warning' when 'info' alternative = 'progress-bar-info' else alternative = '' end if [:active] striped = "progress-bar-striped active" elsif [:striped] striped = "progress-bar-striped" else striped = "" end clazz = [[:class], 'progress-bar', alternative, striped].join(' ').strip() unless [:label] percent_and_label = "<span class='sr-only'>#{percent}%</span>" else percent_and_label = "#{percent}%" end style = ["width: #{percent}%", [:style]].join().strip() id = " id='#{[:id]}'" if [:id] "<div class='#{clazz}'#{id} role='progressbar' aria-valuenow='#{percent}' aria-valuemin='0' aria-valuemax='100' style='#{style}'>#{percent_and_label}</div>" end |