Class: I18nDateRangeGenerator
- Inherits:
-
Object
- Object
- I18nDateRangeGenerator
- Defined in:
- lib/i18n_date_range/i18n_date_range_generator.rb
Overview
Computing range to choose the correct form
Constant Summary collapse
- KIND_NO_END =
:no_end
- KIND_SAME_DAY =
:same_day
- KIND_SAME_MONTH =
:same_month
- KIND_SAME_YEAR =
:same_year
- KIND_OTHER =
:other
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#from_date ⇒ Object
readonly
Returns the value of attribute from_date.
-
#layout ⇒ Object
readonly
Returns the value of attribute layout.
-
#to_date ⇒ Object
readonly
Returns the value of attribute to_date.
Instance Method Summary collapse
-
#initialize(from_date, to_date = nil, format: :short, layout: :one_line) ⇒ I18nDateRangeGenerator
constructor
“format” can be :short or :long.
- #to_s ⇒ Object
Constructor Details
#initialize(from_date, to_date = nil, format: :short, layout: :one_line) ⇒ I18nDateRangeGenerator
“format” can be :short or :long. “layout” can be :one_line or :two_lines
14 15 16 17 18 19 |
# File 'lib/i18n_date_range/i18n_date_range_generator.rb', line 14 def initialize(from_date, to_date = nil, format: :short, layout: :one_line) @from_date = from_date @to_date = to_date @format = format @layout = layout end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
5 6 7 |
# File 'lib/i18n_date_range/i18n_date_range_generator.rb', line 5 def format @format end |
#from_date ⇒ Object (readonly)
Returns the value of attribute from_date.
5 6 7 |
# File 'lib/i18n_date_range/i18n_date_range_generator.rb', line 5 def from_date @from_date end |
#layout ⇒ Object (readonly)
Returns the value of attribute layout.
5 6 7 |
# File 'lib/i18n_date_range/i18n_date_range_generator.rb', line 5 def layout @layout end |
#to_date ⇒ Object (readonly)
Returns the value of attribute to_date.
5 6 7 |
# File 'lib/i18n_date_range/i18n_date_range_generator.rb', line 5 def to_date @to_date end |
Instance Method Details
#to_s ⇒ Object
21 22 23 |
# File 'lib/i18n_date_range/i18n_date_range_generator.rb', line 21 def to_s layout == :two_lines && to_formatted.present? ? from_formatted + '<br>' + to_formatted : from_formatted + to_formatted end |