Sha256: 6ab97e6f2ec2794ce66bc025c95db76bd4b46f53b5affa37e8d6e8d9af0fde60

Contents?: true

Size: 1.17 KB

Versions: 19

Compression:

Stored size: 1.17 KB

Contents

class Symbol
  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Symbol.html]
  [ [%w(capitalize downcase next succ swapcase upcase), {:after => ".to_sym"}],
    [%w(=~ [] empty? length match size), {}]
  ].each { |methods, options| methods.each do |method|
    module_eval <<-end_eval
      def #{method}(*args)
        to_s.#{method}(*args)#{options[:after]}
      end unless method_defined? :#{method}
    end_eval
  end }

  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Symbol.html]
  def <=>(with)
    return nil unless with.is_a? Symbol
    to_s <=> with.to_s
  end unless method_defined? :"<=>"

  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Symbol.html]
  def casecmp(with)
    return nil unless with.is_a? Symbol
    to_s.casecmp(with.to_s)
  end unless method_defined? :casecmp

  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Symbol.html]
  unless ancestors.include? Comparable
    alias_method :dont_override_equal_please, :==
    include Comparable
    alias_method :==,  :dont_override_equal_please
  end
    
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
marcandre-backports-1.8.0 lib/backports/1.9/symbol.rb
marcandre-backports-1.8.1 lib/backports/1.9/symbol.rb
marcandre-backports-1.8.2 lib/backports/1.9/symbol.rb
marcandre-backports-1.8.3 lib/backports/1.9/symbol.rb
marcandre-backports-1.8.4 lib/backports/1.9/symbol.rb
marcandre-backports-1.9.0 lib/backports/1.9/symbol.rb
backports-1.11.2 lib/backports/1.9/symbol.rb
backports-1.11.1 lib/backports/1.9/symbol.rb
backports-1.11.0 lib/backports/1.9/symbol.rb
backports-1.10.3 lib/backports/1.9/symbol.rb
backports-1.10.2 lib/backports/1.9/symbol.rb
backports-1.10.1 lib/backports/1.9/symbol.rb
backports-1.10.0 lib/backports/1.9/symbol.rb
backports-1.8.3 lib/backports/1.9/symbol.rb
backports-1.9.0 lib/backports/1.9/symbol.rb
backports-1.8.4 lib/backports/1.9/symbol.rb
backports-1.8.0 lib/backports/1.9/symbol.rb
backports-1.8.2 lib/backports/1.9/symbol.rb
backports-1.8.1 lib/backports/1.9/symbol.rb