class CckForms::ParameterTypeClass::Float

Represents a floating point value.

Public Instance Methods

build_form(form_builder, options) click to toggle source

HTML input

# File lib/cck_forms/parameter_type_class/float.rb, line 44
def build_form(form_builder, options)
  set_value_in_hash options
  form_builder.number_field :value, {step: 'any', class: 'form-control input-small'}.merge(options)
end
mongoize() click to toggle source
# File lib/cck_forms/parameter_type_class/float.rb, line 6
def mongoize
  value.to_f
end
to_s(_options = nil) click to toggle source
# File lib/cck_forms/parameter_type_class/float.rb, line 10
def to_s(_options = nil)
  options ||= {}
  trailing_zeros = options.fetch(:trailing_zeros, true)
  value.to_f != 0.0 ? value.to_f : ''
  trailing_zeros && value.to_i == value ? value.to_i  : value
end