Class: BootstrapHamlHelpers::Components::ProgressBar
- Inherits:
-
BootstrapHamlHelpers::Component::Base
- Object
- BootstrapHamlHelpers::Component::Base
- BootstrapHamlHelpers::Components::ProgressBar
- Defined in:
- app/models/bootstrap_haml_helpers/components/progress_bar.rb
Instance Attribute Summary
Attributes inherited from BootstrapHamlHelpers::Component::Base
#attributes, #component_options, #content, #content_block, #content_string, #controller, #output_buffer
Instance Method Summary collapse
- #bar(percentage, *args, &block) ⇒ Object
-
#initialize(options = {}, &block) ⇒ ProgressBar
constructor
A new instance of ProgressBar.
Methods inherited from BootstrapHamlHelpers::Component::Base
#add_attribute, #add_attributes, #block_or_string_content, build, #build, #content_type, init_context, teardown_context, #view_context, view_context, #view_context=, view_context=
Methods included from BootstrapHamlHelpers::Component::InheritableTraits
Constructor Details
#initialize(options = {}, &block) ⇒ ProgressBar
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/models/bootstrap_haml_helpers/components/progress_bar.rb', line 6 def initialize( = {}, &block) striped = .delete(:striped) animated = .delete(:animated) type = .delete(:type) super(, &block) add_attribute(:class, "progress-striped") if striped add_attribute(:class, "progress-striped active") if animated add_attribute(:class, "progress-#{type}") if type end |
Instance Method Details
#bar(percentage, *args, &block) ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/models/bootstrap_haml_helpers/components/progress_bar.rb', line 19 def (percentage, *args, &block) = args. type = .delete(:type) type_string = " bar-#{type}" if type view_context.content_tag(:div, nil, class: "bar#{type_string}", style: "width: #{percentage}%") end |