Skip to content

Commit

Permalink
String#chr is 1.9+ only... Thanks to Arto Bendiken. (v.18.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Jun 24, 2010
1 parent 1446eb3 commit 512740d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion VERSION.yml
@@ -1,5 +1,5 @@
---
:minor: 18
:patch: 0
:patch: 1
:build:
:major: 1
4 changes: 2 additions & 2 deletions backports.gemspec
Expand Up @@ -5,11 +5,11 @@

Gem::Specification.new do |s|
s.name = %q{backports}
s.version = "1.18.0"
s.version = "1.18.1"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Marc-Andr\303\251 Lafortune"]
s.date = %q{2010-06-19}
s.date = %q{2010-06-24}
s.description = %q{ Essential backports that enable some of the really nice features of ruby 1.8.7, ruby 1.9 and rails from ruby 1.8.6 and earlier.
}
s.email = %q{github@marc-andre.ca}
Expand Down
5 changes: 0 additions & 5 deletions lib/backports/1.8.7/string.rb
Expand Up @@ -2,11 +2,6 @@ class String
# Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
Backports.alias_method self, :bytesize, :length

# Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
def chr
chars.first
end unless method_defined? :chr

Backports.make_block_optional self, :each_byte, :each_line, :test_on => "abc"

# Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
Expand Down
5 changes: 5 additions & 0 deletions lib/backports/1.9.1/string.rb
Expand Up @@ -5,6 +5,11 @@ def ascii_only?
!(self =~ /[^\x00-\x7f]/)
end unless method_defined? :ascii_only?

# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
def chr
chars.first || ""
end unless method_defined? :chr

# Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/String.html]
def clear
self[0,length] = ""
Expand Down

0 comments on commit 512740d

Please sign in to comment.