class Bh::Classes::ProgressBar
Private Class Methods
animations()
click to toggle source
@return [Hash<Symbol, String>] the classes that Bootstrap requires to
append to the progress bar to make it look animated.
# File lib/bh/classes/progress_bar.rb, line 64 def self.animations HashWithIndifferentAccess.new.tap do |klass| klass[true] = :'progress-bar-striped active' end end
contexts()
click to toggle source
@return [Hash<Symbol, String>] the classes that Bootstrap requires to
append to the progress bar for each possible context.
# File lib/bh/classes/progress_bar.rb, line 45 def self.contexts HashWithIndifferentAccess.new.tap do |klass| klass[:danger] = :'progress-bar-danger' klass[:info] = :'progress-bar-info' klass[:success] = :'progress-bar-success' klass[:warning] = :'progress-bar-warning' end end
stripes()
click to toggle source
@return [Hash<Symbol, String>] the classes that Bootstrap requires to
append to the progress bar to make it look striped.
# File lib/bh/classes/progress_bar.rb, line 56 def self.stripes HashWithIndifferentAccess.new.tap do |klass| klass[true] = :'progress-bar-striped' end end
Public Instance Methods
animated_class()
click to toggle source
@return [#to_s] the class to assign to make the progress bar aniamted.
# File lib/bh/classes/progress_bar.rb, line 17 def animated_class ProgressBar.animations[@options[:animated]] end
aria_values()
click to toggle source
# File lib/bh/classes/progress_bar.rb, line 26 def aria_values {}.tap do |values| values[:'aria-valuemax'] = 100 values[:'aria-valuemin'] = 0 values[:'aria-valuenow'] = percentage end end
context_class()
click to toggle source
@return [#to_s] the context-related class to assign to the progress bar.
# File lib/bh/classes/progress_bar.rb, line 7 def context_class ProgressBar.contexts[@options[:context]] end
label()
click to toggle source
@return [#to_s] the text to display as the label of the progress bar.
# File lib/bh/classes/progress_bar.rb, line 22 def label labels[@options.fetch :label, false] || @options[:label] end
striped_class()
click to toggle source
@return [#to_s] the class to assign to make the progress bar striped.
# File lib/bh/classes/progress_bar.rb, line 12 def striped_class ProgressBar.stripes[@options[:striped]] end
values()
click to toggle source
# File lib/bh/classes/progress_bar.rb, line 34 def values {}.tap do |values| values[:role] = :progressbar values[:style] = "width: #{percentage}%" end end
Private Instance Methods
labels()
click to toggle source
@return [Hash<Symbol, String>] the texts to uses as labels.
# File lib/bh/classes/progress_bar.rb, line 71 def labels HashWithIndifferentAccess.new.tap do |label| label[true] = text label[false] = @app.content_tag(:span, text, class: 'sr-only') end end
percentage()
click to toggle source
# File lib/bh/classes/progress_bar.rb, line 78 def percentage @options.fetch :percentage, 0 end
text()
click to toggle source
# File lib/bh/classes/progress_bar.rb, line 82 def text "#{percentage}%".tap do |text| text << " (#{@options[:context]})" if @options[:context] end end