Class: Aurita::GUI::Time_Field
- Inherits:
-
Form_Field
- Object
- Array
- Element
- Form_Field
- Aurita::GUI::Time_Field
- Defined in:
- lib/aurita-gui/form/time_field.rb
Instance Attribute Summary collapse
-
#hour ⇒ Object
Returns the value of attribute hour.
-
#hour_element ⇒ Object
Returns the value of attribute hour_element.
-
#minute ⇒ Object
Returns the value of attribute minute.
-
#minute_element ⇒ Object
Returns the value of attribute minute_element.
-
#minute_range ⇒ Object
Returns the value of attribute minute_range.
-
#second ⇒ Object
Returns the value of attribute second.
-
#second_element ⇒ Object
Returns the value of attribute second_element.
-
#time_format ⇒ Object
Returns the value of attribute time_format.
Attributes inherited from Form_Field
#data_type, #form, #hidden, #hint, #invalid, #label, #required, #type
Attributes inherited from Element
#attrib, #force_closing_tag, #gui_element_id, #parent, #tag
Instance Method Summary collapse
- #element ⇒ Object
-
#initialize(params, &block) ⇒ Time_Field
constructor
A new instance of Time_Field.
- #value ⇒ Object
- #value=(time) ⇒ Object (also: #set_value)
Methods inherited from Form_Field
#disable!, #disabled=, #editable!, #enable!, #hidden?, #hide!, #invalid!, #invalid?, #optional!, #readonly!, #readonly=, #readonly?, #readonly_element, #required!, #required?, #show!, #to_hidden_field, #to_s
Methods inherited from Element
#+, #<<, #[], #[]=, #add_class, #aurita_gui_element, #clear_floating, #css_classes, #find_by_dom_id, #get_content, #has_content?, #id, #id=, #inspect, #js_init_code, #length, #method_missing, #recurse, #remove_class, #set_content, #string, #swap, #to_ary, #touch, #touched?, #type=, #untouch
Methods included from Marshal_Helper_Class_Methods
Methods included from Marshal_Helper
Constructor Details
#initialize(params, &block) ⇒ Time_Field
Returns a new instance of Time_Field.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/aurita-gui/form/time_field.rb', line 11 def initialize(params, &block) @time_format = params[:time_format] @time_format ||= 'hms' @value = {} @minute_range = params[:minute_range] set_value(params[:value]) params.delete(:minute_range) params.delete(:time_format) params.delete(:hour) params.delete(:minute) params.delete(:second) params.delete(:value) 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
#hour ⇒ Object
Returns the value of attribute hour.
9 10 11 |
# File 'lib/aurita-gui/form/time_field.rb', line 9 def hour @hour end |
#hour_element ⇒ Object
Returns the value of attribute hour_element.
9 10 11 |
# File 'lib/aurita-gui/form/time_field.rb', line 9 def hour_element @hour_element end |
#minute ⇒ Object
Returns the value of attribute minute.
9 10 11 |
# File 'lib/aurita-gui/form/time_field.rb', line 9 def minute @minute end |
#minute_element ⇒ Object
Returns the value of attribute minute_element.
9 10 11 |
# File 'lib/aurita-gui/form/time_field.rb', line 9 def minute_element @minute_element end |
#minute_range ⇒ Object
Returns the value of attribute minute_range.
9 10 11 |
# File 'lib/aurita-gui/form/time_field.rb', line 9 def minute_range @minute_range end |
#second ⇒ Object
Returns the value of attribute second.
9 10 11 |
# File 'lib/aurita-gui/form/time_field.rb', line 9 def second @second end |
#second_element ⇒ Object
Returns the value of attribute second_element.
9 10 11 |
# File 'lib/aurita-gui/form/time_field.rb', line 9 def second_element @second_element end |
#time_format ⇒ Object
Returns the value of attribute time_format.
9 10 11 |
# File 'lib/aurita-gui/form/time_field.rb', line 9 def time_format @time_format end |
Instance Method Details
#element ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/aurita-gui/form/time_field.rb', line 60 def element select_fields = [] @time_format.to_s.split('').each { |c| case c when 'h' then select_fields << hour_element() when 'm' then select_fields << minute_element() when 's' then select_fields << second_element() end } HTML.div(@attrib) { select_fields } end |
#value ⇒ Object
113 114 115 |
# File 'lib/aurita-gui/form/time_field.rb', line 113 def value { :second => @second, :minute => @minute, :hour => @hour } end |
#value=(time) ⇒ Object Also known as: set_value
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/aurita-gui/form/time_field.rb', line 77 def value=(time) case time when Hash then @value = time when Datetime then @value = { :hour => time.hour, :minute => time.month, :second => time.second } when Date then @value = { :hour => time.hour, :minute => time.minute, :second => time.second } when String then value_parts = time.split(':') count = 0 @time_format.scan(/./).each { |c| case c when 'h' then @hour = value_parts[count] @value[:hour] = @hour count += 1 when 'm' then @minute = value_parts[count] @value[:minute] = @minute count += 1 when 's' then @second = value_parts[count] @value[:second] = @second count += 1 end } else end end |