File: compat.rb

package info (click to toggle)
ruby-tmail 1.2.7.1-3%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,712 kB
  • sloc: ruby: 15,207; ansic: 482; yacc: 349; makefile: 30
file content (41 lines) | stat: -rw-r--r-- 724 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#:stopdoc:
unless Enumerable.method_defined?(:map) 
  module Enumerable #:nodoc:
    alias map collect
  end
end

unless Enumerable.method_defined?(:select)
  module Enumerable #:nodoc:
    alias select find_all
  end
end

unless Enumerable.method_defined?(:reject)
  module Enumerable #:nodoc:
    def reject
      result = []
      each do |i|
        result.push i unless yield(i)
      end
      result
    end
  end
end

unless Enumerable.method_defined?(:sort_by)
  module Enumerable #:nodoc:
    def sort_by
      map {|i| [yield(i), i] }.sort.map {|val, i| i }
    end
  end
end

unless File.respond_to?(:read)
  def File.read(fname) #:nodoc:
    File.open(fname) {|f|
      return f.read
    }
  end
end
#:startdoc: