Class: Clot::ModelMultiDateTag

Inherits:
MultiDateTag show all
Includes:
ModelTag
Defined in:
lib/clot/model_date_tags.rb

Direct Known Subclasses

DateSelect, DatetimeSelect, TimeSelect

Instance Method Summary collapse

Methods included from ModelTag

#render, #set_primary_attributes

Methods inherited from MultiDateTag

#personal_attributes, #render, #render_units, #set_primary_attributes, #time_unit

Methods inherited from ClotTag

#initialize, #render

Methods included from TagHelper

#resolve_value, #split_params

Methods included from AttributeSetter

#personal_attributes, #set_attributes, #set_primary_attributes

Constructor Details

This class inherits a constructor from Clot::ClotTag

Instance Method Details

#fill_zeros(val) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/clot/model_date_tags.rb', line 7

def fill_zeros(val)
  if val < 10
    "0#{val}"
  else
    val
  end
end

#get_unit_order(unit) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/clot/model_date_tags.rb', line 27

def get_unit_order(unit)
  case unit
    when "year" then 1
    when "month" then 2
    when "day" then 3
    when "hour" then 4
    when "minute" then 5
    when "second" then 6
  end
end

#set_unit(unit) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/clot/model_date_tags.rb', line 16

def set_unit(unit)
  order = get_unit_order(unit)
  prompt = instance_variable_get("@#{unit}_prompt".to_sym)
  id_string = %{id_string_val:"#{@first_attr}_#{@attribute_name}_#{order}i",}
  name_string = %{name_string_val:"#{@first_attr}[#{@attribute_name}(#{order}i)]",}
  @include_blank && (prompt ||= "prompt:'',")
  line = "#{@time.send(time_unit(unit).to_sym).to_s},#{id_string} #{name_string}#{@minute_step}#{@start_year}#{@use_month_numbers}#{prompt || @prompt}"
  instance_variable_set "@#{unit}",
    "Clot::Select#{unit.capitalize}".constantize.new(".select_#{unit}", line,[])
end