Class: Alchemy::Ingredients::DatetimeView
- Defined in:
- app/components/alchemy/ingredients/datetime_view.rb
Instance Attribute Summary collapse
-
#date_format ⇒ Object
readonly
Returns the value of attribute date_format.
Attributes inherited from BaseView
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(ingredient, date_format: nil, html_options: {}) ⇒ DatetimeView
constructor
A new instance of DatetimeView.
Methods inherited from BaseView
Constructor Details
#initialize(ingredient, date_format: nil, html_options: {}) ⇒ DatetimeView
Returns a new instance of DatetimeView.
8 9 10 11 |
# File 'app/components/alchemy/ingredients/datetime_view.rb', line 8 def initialize(ingredient, date_format: nil, html_options: {}) super(ingredient) @date_format = settings_value(:date_format, value: date_format) end |
Instance Attribute Details
#date_format ⇒ Object (readonly)
Returns the value of attribute date_format.
4 5 6 |
# File 'app/components/alchemy/ingredients/datetime_view.rb', line 4 def date_format @date_format end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 |
# File 'app/components/alchemy/ingredients/datetime_view.rb', line 13 def call if date_format == "rfc822" ingredient.value.to_s(:rfc822) else ::I18n.l(ingredient.value, format: date_format) end.html_safe end |