Sha256: 862ff8d245eca956b8df9265ef604ad5925265a76f75065997aa094e5127a299

Contents?: true

Size: 1.82 KB

Versions: 4

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

4 entries across 4 versions & 1 rubygems

Version Path
csd-0.1.9 lib/csd/extensions/core/string.rb
csd-0.1.8 lib/csd/extensions/core/string.rb
csd-0.1.7 lib/csd/extensions/core/string.rb
csd-0.1.6 lib/csd/extensions/core/string.rb