Sha256: f09064d915e90ab29ea25c6142cdece0baabb8b2b4d504667d216c4eb22f822d

Contents?: true

Size: 626 Bytes

Versions: 5

Compression:

Stored size: 626 Bytes

Contents

module CRMFormatter
  module Helpers

    #CALL: Formatter.new.letter_case_check(street)
    def self.letter_case_check(str)
      if str.present?
        flashes = str&.gsub(/[^ A-Za-z]/, '')&.strip&.split(' ')
        flash = flashes&.reject {|e| e.length < 3 }.join(' ')

        if flash.present?
          has_caps = flash.scan(/[A-Z]/).any?
          has_lows = flash.scan(/[a-z]/).any?
          if !has_caps || !has_lows
            str = str.split(' ')&.each { |el| el.capitalize! if el.gsub(/[^ A-Za-z]/, '')&.strip&.length > 2 }&.join(' ')
          end
        end
        return str
      end
    end


  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
crm_formatter-1.0.7.pre.rc.1 lib/crm_formatter/helpers.rb
crm_formatter-1.0.6.pre.rc.1 lib/crm_formatter/helpers.rb
crm_formatter-1.0.5.pre.rc.1 lib/crm_formatter/helpers.rb
crm_formatter-1.0.4.pre.rc.1 lib/crm_formatter/helpers.rb
crm_formatter-1.0.3.pre.rc.1 lib/crm_formatter/helpers.rb