module Formtastic::Inputs::Base::DatetimePickerish

Public Instance Methods

default_maxlength() click to toggle source
# File lib/formtastic/inputs/base/datetime_pickerish.rb, line 51
def default_maxlength
  default_size
end
default_size() click to toggle source
# File lib/formtastic/inputs/base/datetime_pickerish.rb, line 11
def default_size
  raise NotImplementedError
end
default_step() click to toggle source
# File lib/formtastic/inputs/base/datetime_pickerish.rb, line 55
def default_step
  1
end
extra_input_html_options() click to toggle source
# File lib/formtastic/inputs/base/datetime_pickerish.rb, line 23
def extra_input_html_options
  {
    :type => html_input_type, 
    :size => size, 
    :maxlength => maxlength, 
    :step => step,
    :value => value
  }
end
html_input_type() click to toggle source
# File lib/formtastic/inputs/base/datetime_pickerish.rb, line 7
def html_input_type
  raise NotImplementedError
end
input_html_options() click to toggle source
# File lib/formtastic/inputs/base/datetime_pickerish.rb, line 19
def input_html_options
  super.merge(extra_input_html_options)
end
maxlength() click to toggle source
# File lib/formtastic/inputs/base/datetime_pickerish.rb, line 45
def maxlength
  return options[:maxlength] if options.key?(:maxlength)
  return options[:input_html][:maxlength] if options[:input_html] && options[:input_html].key?(:maxlength)
  default_size
end
size() click to toggle source
# File lib/formtastic/inputs/base/datetime_pickerish.rb, line 33
def size
  return options[:size] if options.key?(:size)
  return options[:input_html][:size] if options[:input_html] && options[:input_html].key?(:size)
  default_size
end
step() click to toggle source
# File lib/formtastic/inputs/base/datetime_pickerish.rb, line 39
def step
  return step_from_macro(options[:input_html][:step]) if options[:input_html] && options[:input_html][:step] && options[:input_html][:step].is_a?(Symbol)
  return options[:input_html][:step] if options[:input_html] && options[:input_html].key?(:step)
  default_step
end
value() click to toggle source
# File lib/formtastic/inputs/base/datetime_pickerish.rb, line 15
def value
  raise NotImplementedError
end

Protected Instance Methods

step_from_macro(sym) click to toggle source
# File lib/formtastic/inputs/base/datetime_pickerish.rb, line 61
def step_from_macro(sym)
  case sym

    # date
    when :day then "1"
    when :seven_days, :week then "7"
    when :two_weeks, :fortnight then "14"
    when :four_weeks then "28"
    when :thirty_days then "30"

    # time
    when :second then "1"
    when :minute then "60"
    when :fifteen_minutes, :quarter_hour then "900"
    when :thirty_minutes, :half_hour then "1800"
    when :sixty_minutes, :hour then "3600"            

    else sym
  end
end