From 07a59079c775675e27f96d68064a8f80c3c431ab Mon Sep 17 00:00:00 2001 From: James McKinney Date: Mon, 17 Oct 2011 01:13:28 -0400 Subject: add String#is_binary_data? in Ruby 1.9 --- lib/ruby19.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 lib/ruby19.rb (limited to 'lib/ruby19.rb') diff --git a/lib/ruby19.rb b/lib/ruby19.rb new file mode 100644 index 000000000..39f48d74e --- /dev/null +++ b/lib/ruby19.rb @@ -0,0 +1,8 @@ +if RUBY_VERSION.to_f == 1.9 + class String + # @see syck/lib/syck/rubytypes.rb + def is_binary_data? + self.count("\x00-\x7F", "^ -~\t\r\n").fdiv(self.size) > 0.3 || self.index("\x00") unless self.empty? + end + end +end \ No newline at end of file -- cgit v1.2.3