class ViewComponent::Storybook::Controls::NumberConfig

Constants

TYPES

Attributes

max[R]
min[R]
step[R]
type[R]

Public Class Methods

new(type, default_value, min: nil, max: nil, step: nil, param: nil, name: nil) click to toggle source
Calls superclass method
# File lib/view_component/storybook/controls/number_config.rb, line 14
def initialize(type, default_value, min: nil, max: nil, step: nil, param: nil, name: nil)
  super(default_value, param: param, name: name)
  @type = type
  @min = min
  @max = max
  @step = step
end

Public Instance Methods

value_from_params(params) click to toggle source
Calls superclass method
# File lib/view_component/storybook/controls/number_config.rb, line 22
def value_from_params(params)
  params_value = super(params)
  if params_value.is_a?(String) && params_value.present?
    (params_value.to_f % 1) > 0 ? params_value.to_f : params_value.to_i
  else
    params_value
  end
end

Private Instance Methods

csf_control_params() click to toggle source
Calls superclass method
# File lib/view_component/storybook/controls/number_config.rb, line 33
def csf_control_params
  super.merge(min: min, max: max, step: step).compact
end