Class: Katalyst::Tables::Cells::DateComponent

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

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_valueObject



21
22
23
# File 'app/components/katalyst/tables/cells/date_component.rb', line 21

def rendered_value
  @relative ? relative_time : absolute_time
end

#valueObject



17
18
19
# File 'app/components/katalyst/tables/cells/date_component.rb', line 17

def value
  super&.to_date
end