Sha256: f1ed6d21bc690ce178eeded4cf5e967d04524c3bf8861ffc394940e1b3d1251c
Contents?: true
Size: 288 Bytes
Versions: 1
Compression:
Stored size: 288 Bytes
Contents
module Mocktail class CreatesIdentifier def create(s, default: "identifier", max_length: 24) id = s.to_s.downcase.gsub(/[^\w\s]/, "").gsub(/^\d+/, "")[0...max_length].strip.gsub(/\s+/, "_") if id.empty? default else id end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mocktail-0.0.3 | lib/mocktail/share/creates_identifier.rb |