Sha256: 3c0309840b3ad7ad8ac6563175dceb6f01a980be42814f6abde8ad3262b3739c

Contents?: true

Size: 609 Bytes

Versions: 4

Compression:

Stored size: 609 Bytes

Contents

module Cape

  module CoreExt

    # Adds methods missing from Ruby's Symbol core class.
    module Symbol

      # Compares the String representation of the Symbol to that of another.
      #
      # @param [Symbol] other
      #
      # @return  [0] the Symbol is equal to _other_
      # @return [-1] the Symbol is lesser than _other_
      # @return  [1] the Symbol is greater than _other_
      def <=>(other)
        to_s <=> other.to_s
      end

    end

  end

end

unless ::Symbol.instance_methods.collect(&:to_s).include?('<=>')
  ::Symbol.class_eval do
    include Cape::CoreExt::Symbol
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cape-1.8.0 lib/cape/core_ext/symbol.rb
cape-1.7.0 lib/cape/core_ext/symbol.rb
cape-1.6.2 lib/cape/core_ext/symbol.rb
cape-1.6.1 lib/cape/core_ext/symbol.rb