Module: UnicodeTools
- Defined in:
- lib/unicode-tools/bidi.rb,
lib/unicode-tools/whitespace.rb,
lib/unicode-tools/string_extension/base.rb,
lib/unicode-tools/string_extension/trim.rb,
lib/unicode-tools/string_extension/squish.rb,
lib/unicode-tools/active_record_extension/squish.rb
Defined Under Namespace
Modules: ActiveRecordExtension, StringExtension
Constant Summary
collapse
- BIDI_OVERRIDE_CHARACTERS_REGEXP =
/\u00E2\u0080[\u008E\u008F\u00AA-\u00AE]/.freeze
- WHITESPACE_CHARS =
%w( \u0009-\u000D \u0085 \u2028 \u2029
\u0020 \u3000 \u1680 \u2000-\u200A
\u205F \u00A0 \u202F \u180E ).freeze
- WHITESPACE_REGEXP =
/[#{WHITESPACE_CHARS.join('')}]+/.freeze
- LEADING_WHITESPACE_REGEXP =
/\A#{WHITESPACE_REGEXP.source}+/.freeze
- TRAILING_WHITESPACE_REGEXP =
/#{WHITESPACE_REGEXP.source}+\z/.freeze
- SURROUNDING_WHITESPACE_REGEXP =
/(\A#{WHITESPACE_REGEXP.source})|(#{WHITESPACE_REGEXP.source}\z)/.freeze
Class Method Summary
collapse
Class Method Details
.has_bidi_override?(string) ⇒ Boolean
8
9
10
|
# File 'lib/unicode-tools/bidi.rb', line 8
def has_bidi_override?(string)
!!(string =~ BIDI_OVERRIDE_CHARACTERS_REGEXP)
end
|
.has_whitespace?(string) ⇒ Boolean
16
17
18
|
# File 'lib/unicode-tools/whitespace.rb', line 16
def has_whitespace?(string)
string.has_whitespace?
end
|
.replace_whitespace(string, replacement = nil, &block) ⇒ Object
36
37
38
|
# File 'lib/unicode-tools/whitespace.rb', line 36
def replace_whitespace(string, replacement = nil, &block)
string.replace_whitespace(replacement, &block)
end
|
.replace_whitespace!(string, replacement = nil, &block) ⇒ Object
40
41
42
|
# File 'lib/unicode-tools/whitespace.rb', line 40
def replace_whitespace!(string, replacement = nil, &block)
string.replace_whitespace!(replacement, &block)
end
|
.squish(string) ⇒ Object
28
29
30
|
# File 'lib/unicode-tools/whitespace.rb', line 28
def squish(string)
string.squish
end
|
.squish!(string) ⇒ Object
32
33
34
|
# File 'lib/unicode-tools/whitespace.rb', line 32
def squish!(string)
string.squish!
end
|
.strip_bidi_override_characters(string) ⇒ Object
12
13
14
|
# File 'lib/unicode-tools/bidi.rb', line 12
def strip_bidi_override_characters(string)
string.gsub(BIDI_OVERRIDE_CHARACTERS_REGEXP, '')
end
|
.strip_bidi_override_characters!(string) ⇒ Object
16
17
18
|
# File 'lib/unicode-tools/bidi.rb', line 16
def strip_bidi_override_characters!(string)
string.gsub!(BIDI_OVERRIDE_CHARACTERS_REGEXP, '')
end
|
.trim(string) ⇒ Object
20
21
22
|
# File 'lib/unicode-tools/whitespace.rb', line 20
def trim(string)
string.trim
end
|
.trim!(string) ⇒ Object
24
25
26
|
# File 'lib/unicode-tools/whitespace.rb', line 24
def trim!(string)
string.trim!
end
|