Class: GovUkDateFields::FormFields
- Inherits:
-
Object
- Object
- GovUkDateFields::FormFields
- Includes:
- ActionView::Context, ActionView::Helpers::TagHelper
- Defined in:
- lib/gov_uk_date_fields/form_fields.rb
Constant Summary collapse
- DATE_SEGMENTS =
{ day: '_dd', month: '_mm', year: '_yyyy', }.freeze
Instance Method Summary collapse
-
#initialize(form, object_name, attribute, options = {}) ⇒ FormFields
constructor
A new instance of FormFields.
- #output ⇒ Object
- #raw_output ⇒ Object
Constructor Details
#initialize(form, object_name, attribute, options = {}) ⇒ FormFields
Returns a new instance of FormFields.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gov_uk_date_fields/form_fields.rb', line 14 def initialize(form, object_name, attribute, ={}) @form = form @object = form.object @object_name = object_name @attribute = attribute @options = @day_value = @object.send("#{@attribute}_dd")&.gsub(/\D/, '') @month_value = @object.send("#{@attribute}_mm")&.gsub(/\D/, '') @year_value = @object.send("#{@attribute}_yyyy")&.gsub(/\D/, '') end |
Instance Method Details
#output ⇒ Object
29 30 31 |
# File 'lib/gov_uk_date_fields/form_fields.rb', line 29 def output raw_output.html_safe end |
#raw_output ⇒ Object
25 26 27 |
# File 'lib/gov_uk_date_fields/form_fields.rb', line 25 def raw_output generate_input_fields end |