Sha256: 648a9dc23d1b698a8942a07d58fba69a98e43ee6e19e604faf67c94ddea6703c
Contents?: true
Size: 1.75 KB
Versions: 3
Compression:
Stored size: 1.75 KB
Contents
module Kernel def ruby_19?; (RUBY_VERSION >= "1.9"); end end if RUBY_VERSION < "1.9" class String require 'enumerator' unless method_defined?(:to_enum) # DON'T USE String#each. Use String#each_line def lines return to_enum(:lines) if !block_given? self.split(/^/).each do |l| yield l end end unless method_defined?(:lines) ## # Returns the numeric, ascii value of the first character # in the string. # # @return [Fixnum] the ascii value of the first character in the string def ord self[0] end unless method_defined?(:ord) end class Object def tap yield self self end unless method_defined?(:tap) end else # 1.9 + # Autoload bug in 1.9 means we have to directly require these. FML. require 'continuation' require 'zlib' require 'stringio' require 'fileutils' class String # String doesn't include Enumerable in Ruby 1.9, so we lose #any?. # Luckily it's quite easy to implement. # # @return [Boolean] does the string have anything in it? def any? size > 0 end end class File ## # This is in ftools in Ruby 1.8.x, but now it's in FileUtils. So # this is essentially an alias to it. Silly ftools, trix are for kids. def self.copy(*args) FileUtils.copy(*args) end ## # This is in ftools in Ruby 1.8.x, but now it's in FileUtils. So # this is essentially an alias to it. Silly ftools, trix are for kids. def self.move(*args) FileUtils.move(*args) end ## # This is in ftools in Ruby 1.8.x, but now it's in FileUtils. So # this is essentially an alias to it. Silly ftools, trix are for kids. def self.makedirs(*args) FileUtils.makedirs(*args) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
amp-0.5.3 | lib/amp/support/ruby_19_compatibility.rb |
amp-0.5.2 | lib/amp/support/ruby_19_compatibility.rb |
amp-0.5.1 | lib/amp/support/ruby_19_compatibility.rb |