Sha256: d44e833f9fd951a5b2fd082075ebef66140dd9b555825e2866c06c71fd733292

Contents?: true

Size: 738 Bytes

Versions: 2

Compression:

Stored size: 738 Bytes

Contents

require 'string-irc'
require 'octospy/url'

module Octospy
  module Extensions
    module String
      def underscore
        self.gsub('::', '/').
          gsub(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2').
          gsub(/([a-z\d])([A-Z])/,'\1_\2').
          tr("-", "_").
          downcase
      end

      def split_by_linefeed_except_blankline
        self.split(/\r\n|\n/).map { |v| v unless v.eql? '' }.compact
      end
      alias_method :split_lfbl, :split_by_linefeed_except_blankline

      def colorize_for_irc
        StringIrc.new(self)
      end

      def shorten_url
        Octospy::Url.shorten self
      end
      alias_method :shorten, :shorten_url
    end
  end
end

::String.__send__ :include, Octospy::Extensions::String

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
octospy-0.0.8 lib/octospy/extensions/string.rb
octospy-0.0.7 lib/octospy/extensions/string.rb