Wrap strings to act like in 1.9
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib add to_i Jan 16, 2011
spec add to_i Jan 16, 2011
Gemfile
Gemfile.lock
Rakefile initial by http://github.com/grosser/project_template Jan 15, 2011
Readme.md
VERSION
string19.gemspec Regenerate gemspec for version 0.0.4 Jan 16, 2011

Readme.md

Stop thinking about differences between 1.9 and 1.8.

size / index / slice / slice! / chars / bytes / [] etc supported

Still some methods missing, fork & pull for what you need!

Install

sudo gem install string19

Usage

# on 1.8 AND 1.9
String19("Á§ÐÁ§Ð").size == 6

# to add a new wrapped method (result is a String19)
class String
  def foo
    'fäää'
  end
end

String19::Wrapped.wrap(:foo) if String19::IS_18
String19('').foo.size == 4

# to add a new delegated method (result is not modified)
class String
  def foo
    42
  end
end

String19::Wrapped.delegate(:foo) if String19::IS_18

String19('').foo == 42

Author

Michael Grosser
grosser.michael@gmail.com
Hereby placed under public domain, do what you want, just do not hold me accountable...