Class: Katalyst::Tables::Cells::DateTimeComponent

Inherits:
Katalyst::Tables::CellComponent show all
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

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_valueObject



23
24
25
# File 'app/components/katalyst/tables/cells/date_time_component.rb', line 23

def rendered_value
  @relative ? relative_time : absolute_time
end

#valueObject



19
20
21
# File 'app/components/katalyst/tables/cells/date_time_component.rb', line 19

def value
  super&.to_datetime
end