Sha256: 24a966e06976073f7986067744efc5cc7d0f7867f87136982fd5c3891becee9d

Contents?: true

Size: 807 Bytes

Versions: 8

Compression:

Stored size: 807 Bytes

Contents

# encoding: utf-8

require 'active_support'
require 'active_support/inflector'
require 'active_support/core_ext/module/aliasing'
require 'active_support/core_ext/string/inflections'


class String
    def cleanup
        indent = (index /^([ \t]+)/; $1) || ''
        regex = /^#{Regexp::escape( indent )}/
        strip.gsub regex, ''
    end

    def oneline
        strip.gsub( /\n\s+/, '' )
    end

    # Annoyingly, the useful version of pluralize in texthelpers isn't in the
    # string core extensions.
    def pluralize_with_count( count )
      count > 1 ? pluralize_without_count : singularize
    end
    alias_method_chain :pluralize, :count
end


class Object
    # Deep duplicate via remarshaling.  Not always applicable.
    def ddup
        Marshal.load( Marshal.dump( self ))
    end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
git-topic-0.1.6.4 lib/core_ext.rb
git-topic-0.1.6.3 lib/core_ext.rb
git-topic-0.1.6.2 lib/core_ext.rb
git-topic-0.1.5 lib/core_ext.rb
git-topic-0.1.4 lib/core_ext.rb
git-topic-0.1.3 lib/util.rb
git-topic-0.1.2 lib/util.rb
git-topic-0.1.1 lib/util.rb