Class: Aurita::GUI::Date_Field
- Inherits:
-
Form_Field
- Object
- Element
- Form_Field
- Aurita::GUI::Date_Field
- Defined in:
- lib/aurita-gui/form/date_field.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#date_format ⇒ Object
Returns the value of attribute date_format.
-
#day ⇒ Object
Returns the value of attribute day.
-
#day_element ⇒ Object
Returns the value of attribute day_element.
-
#month ⇒ Object
Returns the value of attribute month.
-
#month_element ⇒ Object
Returns the value of attribute month_element.
-
#year ⇒ Object
Returns the value of attribute year.
-
#year_element ⇒ Object
Returns the value of attribute year_element.
-
#years ⇒ Object
Returns the value of attribute years.
Attributes inherited from Form_Field
Attributes inherited from Element
#attrib, #content, #parent, #tag, #type
Instance Method Summary collapse
- #element ⇒ Object
-
#initialize(params, &block) ⇒ Date_Field
constructor
A new instance of Date_Field.
- #value ⇒ Object
- #value=(date) ⇒ Object
Methods inherited from Form_Field
#disable!, #editable!, #enable!, #readonly!, #readonly?, #readonly_element, #to_s
Methods inherited from Element
#+, #[], #[]=, #clear_floating, #dom_id, #dom_id=, #each, #empty?, #id, #id=, #length, #method_missing, #string, #to_ary
Constructor Details
#initialize(params, &block) ⇒ Date_Field
Returns a new instance of Date_Field.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/aurita-gui/form/date_field.rb', line 11 def initialize(params, &block) @date_format = params[:date_format] @date_format ||= 'mdy' @year_range = params[:year_range] params.delete(:date_format) params.delete(:date) params.delete(:day) params.delete(:month) params.delete(:year) params.delete(:year_range) super(params, &block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Aurita::GUI::Element
Instance Attribute Details
#date_format ⇒ Object
Returns the value of attribute date_format.
9 10 11 |
# File 'lib/aurita-gui/form/date_field.rb', line 9 def date_format @date_format end |
#day ⇒ Object
Returns the value of attribute day.
9 10 11 |
# File 'lib/aurita-gui/form/date_field.rb', line 9 def day @day end |
#day_element ⇒ Object
Returns the value of attribute day_element.
9 10 11 |
# File 'lib/aurita-gui/form/date_field.rb', line 9 def day_element @day_element end |
#month ⇒ Object
Returns the value of attribute month.
9 10 11 |
# File 'lib/aurita-gui/form/date_field.rb', line 9 def month @month end |
#month_element ⇒ Object
Returns the value of attribute month_element.
9 10 11 |
# File 'lib/aurita-gui/form/date_field.rb', line 9 def month_element @month_element end |
#year ⇒ Object
Returns the value of attribute year.
9 10 11 |
# File 'lib/aurita-gui/form/date_field.rb', line 9 def year @year end |
#year_element ⇒ Object
Returns the value of attribute year_element.
9 10 11 |
# File 'lib/aurita-gui/form/date_field.rb', line 9 def year_element @year_element end |
#years ⇒ Object
Returns the value of attribute years.
9 10 11 |
# File 'lib/aurita-gui/form/date_field.rb', line 9 def years @years end |
Instance Method Details
#element ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/aurita-gui/form/date_field.rb', line 50 def element select_fields = [] @date_format.scan(/./).each { |c| case c when 'y' then select_fields << year_element() when 'm' then select_fields << month_element() when 'd' then select_fields << day_element() end } HTML.div(@attrib) { select_fields } end |
#value ⇒ Object
88 89 90 |
# File 'lib/aurita-gui/form/date_field.rb', line 88 def value { :day => @day, :month => @month, :year => @year } end |
#value=(date) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/aurita-gui/form/date_field.rb', line 67 def value=(date) case date when Hash then @value = date when Datetime then @value = { :year => date.year, :month => date.month, :day => date.day } when Date then @value = { :year => date.year, :month => date.month, :day => date.day } when String then date = Datetime.strptime(date) @value = { :year => date.year, :month => date.month, :day => date.day } else end end |