Sha256: de27fe0b2511398e96cbd560eaae28ff857066964267b5dfbc876a0f8f95cab5

Contents?: true

Size: 777 Bytes

Versions: 10

Compression:

Stored size: 777 Bytes

Contents

# frozen_string_literal: true

module AppEntitlementsStatistics
  module Inflector
    def ai_snakecase
      gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
        .gsub(/([a-z\d])([A-Z])/, '\1_\2')
        .tr('-', '_')
        .gsub(/\s/, '_')
        .gsub(/__+/, '_')
        .downcase
    end

    def ai_camelcase(first_letter: :upper, separators: ['-', '_', '\s'])
      str = dup

      separators.each do |s|
        str = str.gsub(/(?:#{s}+)([a-z])/) { $1.upcase }
      end

      case first_letter
      when :upper, true
        str = str.gsub(/(\A|\s)([a-z])/) { $1 + $2.upcase }
      when :lower, false
        str = str.gsub(/(\A|\s)([A-Z])/) { $1 + $2.downcase }
      end

      str
    end
  end
end

class String
  include AppEntitlementsStatistics::Inflector
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cocoapods-entitlements-statistics-0.1.5 lib/cocoapods-entitlements-statistics/app_entitlements_statistics/core_ext/inflector.rb
cocoapods-entitlements-statistics-0.1.2 lib/cocoapods-entitlements-statistics/app_entitlements_statistics/core_ext/inflector.rb
cocoapods-entitlements-statistics-0.1.1 lib/cocoapods-entitlements-statistics/app_entitlements_statistics/core_ext/inflector.rb
cocoapods-entitlements-statistics-0.1.0 lib/cocoapods-entitlements-statistics/app_entitlements_statistics/core_ext/inflector.rb
cocoapods-entitlements-statistics-0.0.6 lib/cocoapods-entitlements-statistics/app_entitlements_statistics/core_ext/inflector.rb
cocoapods-entitlements-statistics-0.0.5 lib/cocoapods-entitlements-statistics/app_entitlements_statistics/core_ext/inflector.rb
cocoapods-entitlements-statistics-0.0.4 lib/cocoapods-entitlements-statistics/app_entitlements_statistics/core_ext/inflector.rb
cocoapods-entitlements-statistics-0.0.3 lib/cocoapods-entitlements-statistics/app_entitlements_statistics/core_ext/inflector.rb
cocoapods-entitlements-statistics-0.0.2 lib/cocoapods-entitlements-statistics/app_entitlements_statistics/core_ext/inflector.rb
cocoapods-entitlements-statistics-0.0.1 lib/cocoapods-entitlements-statistics/app_entitlements_statistics/core_ext/inflector.rb