Sha256: 705d601541ec2d14f70cfed5cae0a211cab8e001e45723cef08e051c592cf546

Contents?: true

Size: 721 Bytes

Versions: 2

Compression:

Stored size: 721 Bytes

Contents

module ExtForm
  module Layouts
    class DefaultLayout
      include BaseLayout

      # Internal: decide option width whether is available,
      # possible formats are number% or number.
      #
      # width - option width
      #
      # Returns true or false.
      def width_available?(width)
        width && width.match(/^\d+\.?\d?$/)
      end

      def measure_available?(measure)
        %w(% px pt em cm).include?(measure)
      end

      def calc_actual_width
        self.layout.flatten.map(&:to_f).sum
      end

      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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ext_form-0.1.5 lib/ext_form/layouts/default_layout.rb
ext_form-0.1.4 lib/ext_form/layouts/default_layout.rb