Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/direction_detector.rb

Overview

Copyright © 2010-2011, Diaspora Inc. This file is

licensed under the Affero General Public License version 3 or later.  See
the COPYRIGHT file.

Constant Summary collapse

RTL_CLEANER_REGEXES =

mention, tag

[ /@[^ ]+|#[^ ]+/u, # mention, tag
  /^RT[: ]{1}| RT | RT: |[♺♻:]/u # retweet
]

Instance Method Summary collapse

Instance Method Details

#cleaned_is_rtl?Boolean

Diaspora specific

Returns:

  • (Boolean)

20
21
22
23
24
25
26
# File 'lib/direction_detector.rb', line 20

def cleaned_is_rtl?
  string = String.new(self)
  RTL_CLEANER_REGEXES.each do |cleaner|
    string.gsub!(cleaner, '')
  end
  string.is_rtl?
end

#is_rtl?Boolean

Returns:

  • (Boolean)

13
14
15
16
17
# File 'lib/direction_detector.rb', line 13

def is_rtl?
  return false if self.strip.empty?
  detector = StringDirection::Detector.new(:dominant)
  detector.rtl? self
end