Sha256: 0313fdd1b8471ea032e3d43d8119b02a6877cf86db120b6234dab0a27e1062ca
Contents?: true
Size: 606 Bytes
Versions: 21
Compression:
Stored size: 606 Bytes
Contents
# frozen_string_literal: true require 'active_support/inflector' module EacRubyUtils class Inflector class << self VARIABLE_NAME_PATTERN = /[_a-z][_a-z0-9]*/i.freeze def variableize(string) r = ::ActiveSupport::Inflector.transliterate(string).gsub(/[^_a-z0-9]/i, '_') .gsub(/_+/, '_').gsub(/_\z/, '').gsub(/\A_/, '').downcase m = VARIABLE_NAME_PATTERN.match(r) return r if m raise ::ArgumentError, "Invalid variable name \"#{r}\" was generated " \ "from string \"#{string}\"" end end end end
Version data entries
21 entries across 21 versions & 3 rubygems