Class: ActionView::Storybook::Controls::NumberConfig
- Inherits:
-
ControlConfig
- Object
- ControlConfig
- ActionView::Storybook::Controls::NumberConfig
- Defined in:
- lib/action_view/storybook/controls/number_config.rb
Constant Summary collapse
- TYPES =
%i[number range].freeze
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
-
#step ⇒ Object
readonly
Returns the value of attribute step.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from ControlConfig
Instance Method Summary collapse
-
#initialize(type, param, value, min: nil, max: nil, step: nil, name: nil) ⇒ NumberConfig
constructor
A new instance of NumberConfig.
- #value_from_param(param) ⇒ Object
Methods inherited from ControlConfig
Constructor Details
#initialize(type, param, value, min: nil, max: nil, step: nil, name: nil) ⇒ NumberConfig
Returns a new instance of NumberConfig.
14 15 16 17 18 19 20 |
# File 'lib/action_view/storybook/controls/number_config.rb', line 14 def initialize(type, param, value, min: nil, max: nil, step: nil, name: nil) super(param, value, name: name) @type = type @min = min @max = max @step = step end |
Instance Attribute Details
#max ⇒ Object (readonly)
Returns the value of attribute max.
9 10 11 |
# File 'lib/action_view/storybook/controls/number_config.rb', line 9 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
9 10 11 |
# File 'lib/action_view/storybook/controls/number_config.rb', line 9 def min @min end |
#step ⇒ Object (readonly)
Returns the value of attribute step.
9 10 11 |
# File 'lib/action_view/storybook/controls/number_config.rb', line 9 def step @step end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/action_view/storybook/controls/number_config.rb', line 9 def type @type end |
Instance Method Details
#value_from_param(param) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/action_view/storybook/controls/number_config.rb', line 22 def value_from_param(param) if param.is_a?(String) && param.present? (param.to_f % 1) > 0 ? param.to_f : param.to_i else super(param) end end |