Module: Formtastic::Inputs::Base::Numeric

Included in:
NumberInput, RangeInput
Defined in:
lib/formtastic/inputs/base/numeric.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) in_option



38
39
40
# File 'lib/formtastic/inputs/base/numeric.rb', line 38

def in_option
  options[:in]
end

- (Object) input_html_options



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/formtastic/inputs/base/numeric.rb', line 5

def input_html_options
  defaults = super

  # override rails default size - does not apply to numeric inputs
  #@todo document/spec
  defaults[:size] = nil
  
  if in_option
    defaults[:min] = in_option.to_a.min
    defaults[:max] = in_option.to_a.max
  else
    defaults[:min]  ||= min_option
    defaults[:max]  ||= max_option
  end
  defaults[:step] ||= step_option
  defaults
end

- (Object) max_option



33
34
35
36
# File 'lib/formtastic/inputs/base/numeric.rb', line 33

def max_option
  return options[:max] if options.key?(:max)
  validation_max
end

- (Object) min_option



28
29
30
31
# File 'lib/formtastic/inputs/base/numeric.rb', line 28

def min_option
  return options[:min] if options.key?(:min)
  validation_min
end

- (Object) step_option



23
24
25
26
# File 'lib/formtastic/inputs/base/numeric.rb', line 23

def step_option
  return options[:step] if options.key?(:step)
  validation_step
end

- (Object) wrapper_html_options



42
43
44
45
# File 'lib/formtastic/inputs/base/numeric.rb', line 42

def wrapper_html_options
  new_class = [super[:class], "numeric", "stringish"].compact.join(" ")
  super.merge(:class => new_class)
end