Class: Ui::Progress::Component
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Ui::Progress::Component
- Defined in:
- lib/uikit_rails/templates/components/progress/component.rb
Overview
Progress bar showing completion percentage.
Instance Attribute Summary collapse
-
#html_attrs ⇒ Object
readonly
Returns the value of attribute html_attrs.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value: 0, max: 100, **html_attrs) ⇒ Component
constructor
A new instance of Component.
- #percentage ⇒ Object
Constructor Details
#initialize(value: 0, max: 100, **html_attrs) ⇒ Component
Returns a new instance of Component.
9 10 11 12 13 14 |
# File 'lib/uikit_rails/templates/components/progress/component.rb', line 9 def initialize(value: 0, max: 100, **html_attrs) @value = value.to_i @max = max.to_i @html_attrs = html_attrs super() end |
Instance Attribute Details
#html_attrs ⇒ Object (readonly)
Returns the value of attribute html_attrs.
7 8 9 |
# File 'lib/uikit_rails/templates/components/progress/component.rb', line 7 def html_attrs @html_attrs end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
7 8 9 |
# File 'lib/uikit_rails/templates/components/progress/component.rb', line 7 def max @max end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/uikit_rails/templates/components/progress/component.rb', line 7 def value @value end |
Instance Method Details
#percentage ⇒ Object
16 17 18 19 20 |
# File 'lib/uikit_rails/templates/components/progress/component.rb', line 16 def percentage return 0 if max.zero? [(value.to_f / max * 100).round, 100].min end |