123456789_123456789_123456789_123456789_123456789_

Class: ActionView::Helpers::Tags::DateSelect

Do not use. This class is for internal use only.

Constant Summary

::ActionView::Helpers::TagHelper - Included

ARIA_PREFIXES, BOOLEAN_ATTRIBUTES, CLASS_PREFIXES, DATA_PREFIXES, PRE_CONTENT_STRINGS, TAG_TYPES

::ActionView::Helpers::ContentExfiltrationPreventionHelper - Included

CLOSE_CDATA_COMMENT, CLOSE_FORM_TAG, CLOSE_OPTION_TAG, CLOSE_QUOTES_COMMENT, CONTENT_EXFILTRATION_PREVENTION_MARKUP

Class Method Summary

Instance Attribute Summary

Instance Method Summary

SelectRenderer - Included

Base - Inherited

::ActionView::Helpers::ActiveModelInstanceTag - Included

::ActionView::Helpers::FormTagHelper - Included

#button_tag

Creates a button element that defines a submit button, reset button or a generic button which can be used in JavaScript, for example.

#check_box_tag
#checkbox_tag

Creates a check box form input tag.

#color_field_tag

Creates a text field of type "color".

#datalist_tag

Creates a datalist form element.

#date_field_tag

Creates a text field of type "date".

#datetime_field_tag

Creates a text field of type "datetime-local".

#datetime_local_field_tag
#email_field_tag

Creates a text field of type "email".

#field_id

Generate an HTML id attribute value for the given name and field combination.

#field_name

Generate an HTML name attribute value for the given name and field combination.

#field_set_tag

Creates a field set for grouping HTML form elements.

#fieldset_tag
#file_field_tag

Creates a file upload field.

#form_tag

Starts a form tag that points the action to a URL configured with url_for_options just like ActionController::Base#url_for.

#hidden_field_tag

Creates a hidden form input field used to transmit data that would be lost due to HTTP's statelessness or data that should be hidden from the user.

#image_submit_tag

Displays an image which when clicked will submit the form.

#label_tag

Creates a label element.

#month_field_tag

Creates a text field of type "month".

#number_field_tag

Creates a number field.

#password_field_tag

Creates a password field, a masked text field that will hide the users input behind a mask character.

#phone_field_tag
#radio_button_tag

Creates a radio button; use groups of radio buttons named the same to allow users to select from a group of options.

#range_field_tag

Creates a range form element.

#search_field_tag

Creates a text field of type "search".

#select_tag

Creates a dropdown selection box, or if the :multiple option is set to true, a multiple choice selection box.

#submit_tag

Creates a submit button with the text value as the caption.

#telephone_field_tag

Creates a text field of type "tel".

#text_area_tag
#text_field_tag

Creates a standard text field; use these text fields to input smaller chunks of text like a username or a search query.

#textarea_tag

Creates a text input area; use a textarea for longer text inputs such as blog posts or descriptions.

#time_field_tag

Creates a text field of type "time".

#url_field_tag

Creates a text field of type "url".

#utf8_enforcer_tag

Creates the hidden UTF-8 enforcer tag.

#week_field_tag

Creates a text field of type "week".

#convert_direct_upload_option_to_url, #extra_tags_for_form, #form_tag_html, #form_tag_with_body, #html_options_for_form,
#sanitize_to_id
#set_default_disable_with

::ActionView::Helpers::ContentExfiltrationPreventionHelper - Included

::ActionView::Helpers::TextHelper - Included

#concat

The preferred method of outputting text in your views is to use the <%= "text" %> eRuby syntax.

#current_cycle

Returns the current cycle string after a cycle has been started.

#cycle

Creates a Cycle object whose to_s method cycles through elements of an array every time it is called.

#excerpt

Extracts the first occurrence of phrase plus surrounding text from text.

#highlight

Highlights occurrences of phrases in text by formatting them with a highlighter string.

#pluralize

Attempts to pluralize the singular word unless count is 1.

#reset_cycle

Resets a cycle so that it starts from the first element the next time it is called.

#safe_concat,
#simple_format

Returns text transformed into HTML using simple formatting rules.

#truncate

Truncates text if it is longer than a specified :length.

#word_wrap

Wraps the text into lines no longer than line_width width.

#cut_excerpt_part,
#get_cycle

The cycle helpers need to store the cycles in a place that is guaranteed to be reset every time a page is rendered, so it uses an instance variable of ::ActionView::Base.

#set_cycle, #split_paragraphs

::ActionView::Helpers::SanitizeHelper - Included

#sanitize

Sanitizes HTML input, stripping all but known-safe tags and attributes.

#sanitize_css

Sanitizes a block of CSS code.

#strip_links

Strips all link tags from html leaving just the link text.

#strip_tags

Strips all HTML tags from html, including comments and special characters.

::ActionView::Helpers::UrlHelper - Included

#mail_to

Creates a mailto link tag to the specified email_address, which is also used as the name of the link unless name is specified.

#phone_to

Creates a TEL anchor link tag to the specified phone_number.

#sms_to

Creates an SMS anchor link tag to the specified phone_number.

#url_for

Basic implementation of url_for to allow use helpers without routes existence.

#_back_url, #_filtered_referrer

::ActionView::Helpers::TagHelper - Included

#cdata_section

Returns a CDATA section with the given content.

#class_names
#content_tag

Returns an HTML block tag of type name surrounding the content.

#escape_once

Returns an escaped version of html without affecting existing escaped entities.

#tag

Modern syntax.

#token_list

Returns a string of tokens built from args.

#build_tag_values, #ensure_valid_html5_tag_name, #tag_builder

::ActionView::Helpers::OutputSafetyHelper - Included

#raw

This method outputs without escaping a string.

#safe_join

This method returns an HTML safe string similar to what Array#join would return.

#to_sentence

Converts the array to a comma-separated sentence where the last element is joined by the connector word.

::ActionView::Helpers::CaptureHelper - Included

#capture

The capture method extracts part of a template as a string object.

#content_for

Calling content_for stores a block of markup in an identifier for later use.

#content_for?

content_for? checks whether any content has been captured yet using content_for.

#provide

The same as content_for but when used with streaming flushes straight back to the layout.

#with_output_buffer

Use an alternate output buffer for the duration of the block.

Constructor Details

.new(object_name, method_name, template_object, options, html_options) ⇒ DateSelect

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tags/date_select.rb', line 11

def initialize(object_name, method_name, template_object, options, html_options)
  @html_options = html_options

  super(object_name, method_name, template_object, options)
end

Class Method Details

.select_type

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tags/date_select.rb', line 22

def select_type
  @select_type ||= name.split("::").last.sub("Select", "").downcase
end

Instance Method Details

#datetime_selector(options, html_options) (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tags/date_select.rb', line 32

def datetime_selector(options, html_options)
  datetime = options.fetch(:selected) { value || default_datetime(options) }
  @auto_index ||= nil

  options = options.dup
  options[:field_name]           = @method_name
  options[:include_position]     = true
  options[:prefix]             ||= @object_name
  options[:index]                = @auto_index if @auto_index && !options.has_key?(:index)

  DateTimeSelector.new(datetime, options, html_options)
end

#default_datetime(options) (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tags/date_select.rb', line 45

def default_datetime(options)
  return if options[:include_blank] || options[:prompt]

  case options[:default]
  when nil
    Time.current
  when Date, Time
    options[:default]
  else
    default = options[:default].dup

    # Rename :minute and :second to :min and :sec
    default[:min] ||= default[:minute]
    default[:sec] ||= default[:second]

    time = Time.current

    [:year, :month, :day, :hour, :min, :sec].each do |key|
      default[key] ||= time.public_send(key)
    end

    Time.utc(
      default[:year], default[:month], default[:day],
      default[:hour], default[:min], default[:sec]
    )
  end
end

#render

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tags/date_select.rb', line 17

def render
  error_wrapping(datetime_selector(@options, @html_options).public_send("select_#{select_type}").html_safe)
end

#select_type (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/helpers/tags/date_select.rb', line 28

def select_type
  self.class.select_type
end