Automatic detection of text direction (ltr, rtl or bidi) for strings in Ruby