Class: ExtForm::Layouts::DefaultLayout
- Inherits:
-
Object
- Object
- ExtForm::Layouts::DefaultLayout
- Includes:
- BaseLayout
- Defined in:
- lib/ext_form/layouts/default_layout.rb
Instance Method Summary collapse
- #calc_actual_width ⇒ Object
- #calculate_input_width(max_width, label_width, spacing, cols_sum, c) ⇒ Object
- #measure_available?(measure) ⇒ Boolean
-
#width_available?(width) ⇒ Boolean
Internal: decide option width whether is available, possible formats are number% or number.
Methods included from BaseLayout
#calculate_layout, #input_width, #label_width, #layout_available?, #setup_config
Instance Method Details
#calc_actual_width ⇒ Object
20 21 22 |
# File 'lib/ext_form/layouts/default_layout.rb', line 20 def calc_actual_width self.layout.flatten.map(&:to_f).sum end |
#calculate_input_width(max_width, label_width, spacing, cols_sum, c) ⇒ Object
24 25 26 |
# File 'lib/ext_form/layouts/default_layout.rb', line 24 def calculate_input_width(max_width, label_width, spacing, cols_sum, c) ((max_width.to_f - 2 * spacing.to_f) / cols_sum * c - label_width.to_f).to_s end |
#measure_available?(measure) ⇒ Boolean
16 17 18 |
# File 'lib/ext_form/layouts/default_layout.rb', line 16 def measure_available?(measure) %w(% px pt em cm).include?(measure) end |
#width_available?(width) ⇒ Boolean
Internal: decide option width whether is available, possible formats are number% or number.
width - option width
Returns true or false.
12 13 14 |
# File 'lib/ext_form/layouts/default_layout.rb', line 12 def width_available?(width) width && width.match(/^\d+\.?\d?$/) end |