Sha256: b6751c8651e316ecd7760296eb8d22a494c195bc2694fb9bb218b4490ad3e55f

Contents?: true

Size: 759 Bytes

Versions: 16

Compression:

Stored size: 759 Bytes

Contents

module Aether
  module String
    def camelcase
      return self.gsub(/^./) { |l| l.capitalize } if !match(/[_-]/)
      altered_self = self.downcase.capitalize
      altered_self.scan(/[_-][a-zA-Z]/).each do |match|
        altered_self.gsub!(match, match[1].upcase)
      end

      altered_self
    end

    def camelcase!
      self.replace camel_case
    end

    def filename
      return self.gsub(/-/, "_") if !match(/[A-Z]/)
      altered_self = self.strip

      altered_self.scan(/[A-Z]/).each do |match|
        altered_self.gsub!(match, "_#{match.downcase}")
      end

      altered_self.sub(/^_/, "").gsub(/_{2,}+/, "_").downcase
    end

    def filename!
      self.replace file_name
    end
  end
end

String.send(:include, Aether::String)

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aetherg-0.3.3 lib/aetherg/string.rb
aetherg-0.3.2 lib/aetherg/string.rb
aetherg-0.3.1 lib/aetherg/string.rb
aetherg-0.2.7 lib/aetherg/string.rb
aetherg-0.2.5 lib/aetherg/string.rb
aetherg-0.2.2 lib/aetherg/string.rb
aetherg-0.2.1 lib/aetherg/string.rb
aetherg-0.2.0 lib/aetherg/string.rb
aetherg-0.1.8 lib/aetherg/string.rb
aetherg-0.1.7 lib/aetherg/string.rb
aetherg-0.1.5 lib/aetherg/string.rb
aetherg-0.1.4 lib/aetherg/string.rb
aetherg-0.1.3 lib/aetherg/string.rb
aetherg-0.1.2 lib/aetherg/string.rb
aetherg-0.1.1 lib/aetherg/string.rb
aetherg-0.1.0 lib/aetherg/string.rb