Class: AhoyCaptain::Stats::ContainerComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- AhoyCaptain::Stats::ContainerComponent
- Defined in:
- app/components/ahoy_captain/stats/container_component.rb
Instance Method Summary collapse
- #formatted(value) ⇒ Object
-
#initialize(url, label, value, formatter, selected = false) ⇒ ContainerComponent
constructor
A new instance of ContainerComponent.
- #number_to_duration(duration) ⇒ Object
Constructor Details
#initialize(url, label, value, formatter, selected = false) ⇒ ContainerComponent
Returns a new instance of ContainerComponent.
4 5 6 7 8 9 10 |
# File 'app/components/ahoy_captain/stats/container_component.rb', line 4 def initialize(url, label, value, formatter, selected = false) @url = url @label = label @value = value @formatter = formatter @selected = selected end |
Instance Method Details
#formatted(value) ⇒ Object
12 13 14 |
# File 'app/components/ahoy_captain/stats/container_component.rb', line 12 def formatted(value) public_send(@formatter, value) end |
#number_to_duration(duration) ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/components/ahoy_captain/stats/container_component.rb', line 17 def number_to_duration(duration) if duration "#{duration.in_minutes.to_i}M #{duration.parts[:seconds].to_i}S" else "0M 0S" end end |