Class: Tempora::TimePeriodFormatter
- Inherits:
-
Object
- Object
- Tempora::TimePeriodFormatter
- Defined in:
- lib/tempora/formatter.rb
Defined Under Namespace
Classes: I18nScopeKeyFinder
Constant Summary collapse
- I18nScopeKeys =
i(same_day same_month same_year different_year).freeze
- I18nScopeKeysIdentifiers =
{ begin: :from, end: :till}
Instance Method Summary collapse
-
#initialize(timeperiod, format: :long) ⇒ TimePeriodFormatter
constructor
format: [:default, :short, :long] -> see I18n.localize.
- #render ⇒ Object
Constructor Details
#initialize(timeperiod, format: :long) ⇒ TimePeriodFormatter
format: [:default, :short, :long] -> see I18n.localize
7 8 9 10 |
# File 'lib/tempora/formatter.rb', line 7 def initialize(timeperiod, format: :long) @timeperiod = timeperiod @format = format end |
Instance Method Details
#render ⇒ Object
12 13 14 15 16 |
# File 'lib/tempora/formatter.rb', line 12 def render from = I18n.l @timeperiod.begin, format: format_for(:from) till = I18n.l @timeperiod.end, format: format_for(:till) [from, till].reject(&:empty?).join ' – ' end |