Sha256: 6480ac0f334292a012a6f2caaac6331a3df4acbf3c452efbec9c4c1827ce4bfa

Contents?: true

Size: 937 Bytes

Versions: 6

Compression:

Stored size: 937 Bytes

Contents

module Aetherg
  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

    def present?
      !self.nil? && !self.empty?
    end
  end

  module Array
    def present?
      !self.nil? && !self.empty?
    end
  end
end

String.send(:include, Aetherg::String)
Array.send(:include, Aetherg::Array)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
aetherg-0.5.1 lib/aetherg/string.rb
aetherg-0.5.0 lib/aetherg/string.rb
aetherg-0.5.0.beta3 lib/aetherg/string.rb
aetherg-0.5.0.beta2 lib/aetherg/string.rb
aetherg-0.5.0.beta lib/aetherg/string.rb
aetherg-0.3.4 lib/aetherg/string.rb