Sha256: 688cdd1b8df9e761ab17e2105c8f18694e207f03b4fd9168b31d42c52857bf08

Contents?: true

Size: 592 Bytes

Versions: 1

Compression:

Stored size: 592 Bytes

Contents

module FormObject
  module Utils
    module StringConverter

      def self.integration_name( word )
        name = word.split('::').last
        underscore(name)
      end

      def self.form_name( word )
        name = word.split('::').last
        name.gsub!(/Form/, '')
        underscore(name).to_sym
      end

      protected

      def self.underscore( original_word, options = {} )
        word = original_word.to_s.dup
        word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
        word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
        word.downcase!
        word
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
form_object-0.1.1 lib/form_object/utils/string_converter.rb