Class: Katalyst::Tables::Cells::DateTimeComponent
- Inherits:
-
Katalyst::Tables::CellComponent
- Object
- ViewComponent::Base
- Katalyst::Tables::CellComponent
- Katalyst::Tables::Cells::DateTimeComponent
- Includes:
- ActionView::Helpers::DateHelper
- Defined in:
- app/components/katalyst/tables/cells/date_time_component.rb
Overview
Formats the value as a datetime
Instance Attribute Summary
Attributes inherited from Katalyst::Tables::CellComponent
#collection, #column, #record, #row
Instance Method Summary collapse
-
#initialize(format:, relative:) ⇒ DateTimeComponent
constructor
A new instance of DateTimeComponent.
- #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:) ⇒ DateTimeComponent
Returns a new instance of DateTimeComponent.
12 13 14 15 16 17 |
# File 'app/components/katalyst/tables/cells/date_time_component.rb', line 12 def initialize(format:, relative:, **) super(**) @format = format @relative = relative end |
Instance Method Details
#rendered_value ⇒ Object
23 24 25 |
# File 'app/components/katalyst/tables/cells/date_time_component.rb', line 23 def rendered_value @relative ? relative_time : absolute_time end |
#value ⇒ Object
19 20 21 |
# File 'app/components/katalyst/tables/cells/date_time_component.rb', line 19 def value super&.to_datetime end |