Class: Katalyst::Tables::Cells::DateComponent
- Inherits:
-
Katalyst::Tables::CellComponent
- Object
- ViewComponent::Base
- Katalyst::Tables::CellComponent
- Katalyst::Tables::Cells::DateComponent
- Defined in:
- app/components/katalyst/tables/cells/date_component.rb
Overview
Formats the value as a date
Instance Attribute Summary
Attributes inherited from Katalyst::Tables::CellComponent
#collection, #column, #record, #row
Instance Method Summary collapse
-
#initialize(format:, relative:) ⇒ DateComponent
constructor
A new instance of DateComponent.
- #rendered_value ⇒ Object
- #value ⇒ Object
Methods inherited from Katalyst::Tables::CellComponent
#call, #heading?, #inspect, #label, #to_s, #with_content_wrapper
Constructor Details
#initialize(format:, relative:) ⇒ DateComponent
Returns a new instance of DateComponent.
10 11 12 13 14 15 |
# File 'app/components/katalyst/tables/cells/date_component.rb', line 10 def initialize(format:, relative:, **) super(**) @format = format @relative = relative end |
Instance Method Details
#rendered_value ⇒ Object
21 22 23 |
# File 'app/components/katalyst/tables/cells/date_component.rb', line 21 def rendered_value @relative ? relative_time : absolute_time end |
#value ⇒ Object
17 18 19 |
# File 'app/components/katalyst/tables/cells/date_component.rb', line 17 def value super&.to_date end |