Sha256: 3e7128c2e625aaa445d53d9159d5dd08b2506758f41e51aeaf749efc25b3f377

Contents?: true

Size: 1.82 KB

Versions: 14

Compression:

Stored size: 1.82 KB

Contents

# -*- encoding: UTF-8 -*-
require 'csd/vendor/term/ansicolor'
require 'csd/vendor/active_support/inflector'

module CSD
  module Extensions
    module Core
      # This module comprises extensions to String objects.
      #
      module String
        
        # Adds a double-quote to the beginning and the end of a +String+.
        #
        # ==== Example
        #
        #   'Hello World'.enquote    # => '`Hello World´'
        #
        def enquote
          %Q{"#{self}"}
        end
        
        # See CSD::Vendor::ActiveSupport::Inflector#constantize
        #
        def constantize
          Vendor::ActiveSupport::Inflector.constantize(self)
        end
        
        # See CSD::Vendor::ActiveSupport::Inflector#camelize
        #
        def camelize
          Vendor::ActiveSupport::Inflector.camelize(self)
        end
        
        # See CSD::Vendor::ActiveSupport::Inflector#demodulize
        #
        def demodulize
          Vendor::ActiveSupport::Inflector.demodulize(self)
        end
        
        # See CSD::Vendor::ActiveSupport::Inflector#underscore. Note that there is
        # a name conflict with <tt>String#underscore</tt> provided by CSD::Vendor::Term::ANSIColor,
        # which is why this method is renamed to +underscorize+.
        # 
        def underscorize
          Vendor::ActiveSupport::Inflector.underscore(self)
        end
        
        # Just an alias to the more logical wording of this method
        #
        def starts_with?(*args) #:nodoc:
          start_with?(*args)
        end
        
        # Just an alias to the more logical wording of this method
        #
        def ends_with?(*args) #:nodoc:
          end_with?(*args)
        end
        
      end
    end
  end
end

class String #:nodoc:
  include CSD::Vendor::Term::ANSIColor
  include CSD::Extensions::Core::String
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
csd-0.3.1 lib/csd/extensions/core/string.rb
csd-0.3.0 lib/csd/extensions/core/string.rb
csd-0.2.2 lib/csd/extensions/core/string.rb
csd-0.2.1 lib/csd/extensions/core/string.rb
csd-0.2.0 lib/csd/extensions/core/string.rb
csd-0.1.18 lib/csd/extensions/core/string.rb
csd-0.1.17 lib/csd/extensions/core/string.rb
csd-0.1.16 lib/csd/extensions/core/string.rb
csd-0.1.15 lib/csd/extensions/core/string.rb
csd-0.1.14 lib/csd/extensions/core/string.rb
csd-0.1.13 lib/csd/extensions/core/string.rb
csd-0.1.12 lib/csd/extensions/core/string.rb
csd-0.1.11 lib/csd/extensions/core/string.rb
csd-0.1.10 lib/csd/extensions/core/string.rb