unicode-multibyte 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.Rakefile.swp +0 -0
- data/.unicode-multibyte.gemspec.swp +0 -0
- data/lib/unicodechars/multibyte/chars.rb +5 -5
- data/unicode-multibyte-0.2.5.gem +0 -0
- data/unicode-multibyte.gemspec +1 -1
- metadata +4 -3
data/.Rakefile.swp
CHANGED
Binary file
|
Binary file
|
@@ -10,12 +10,12 @@ module UnicodeMultibyte::Multibyte
|
|
10
10
|
# String methods are proxied through the Chars object, and can be accessed through the +chars+ method. Methods
|
11
11
|
# which would normally return a String object now return a Chars object so methods can be chained.
|
12
12
|
#
|
13
|
-
# "The Perfect String ".
|
13
|
+
# "The Perfect String ".multibyte_chars.downcase.strip.normalize #=> "the perfect string"
|
14
14
|
#
|
15
15
|
# Chars objects are perfectly interchangeable with String objects as long as no explicit class checks are made.
|
16
16
|
# If certain methods do explicitly check the class, call +to_s+ before you pass chars objects to them.
|
17
17
|
#
|
18
|
-
# bad.explicit_checking_method "T".
|
18
|
+
# bad.explicit_checking_method "T".multibyte_chars.downcase.to_s
|
19
19
|
#
|
20
20
|
# The actual operations on the string are delegated to handlers. Theoretically handlers can be implemented for
|
21
21
|
# any encoding, but the default handler handles UTF-8. This handler is set during initialization, if you want to
|
@@ -80,11 +80,11 @@ module UnicodeMultibyte::Multibyte
|
|
80
80
|
# Works just like String#split, with the exception that the items in the resulting list are Chars
|
81
81
|
# instances instead of String. This makes chaining methods easier.
|
82
82
|
def split(*args)
|
83
|
-
@string.split(*args).map { |i| i.
|
83
|
+
@string.split(*args).map { |i| i.multibyte_chars }
|
84
84
|
end
|
85
85
|
|
86
86
|
# Gsub works exactly the same as gsub on a normal string.
|
87
|
-
def gsub(*a, &b); @string.gsub(*a, &b).
|
87
|
+
def gsub(*a, &b); @string.gsub(*a, &b).multibyte_chars; end
|
88
88
|
|
89
89
|
# Like String.=~ only it returns the character offset (in codepoints) instead of the byte offset.
|
90
90
|
def =~(other)
|
@@ -114,7 +114,7 @@ module UnicodeMultibyte::Multibyte
|
|
114
114
|
end
|
115
115
|
|
116
116
|
if result.kind_of?(String)
|
117
|
-
result.
|
117
|
+
result.multibyte_chars
|
118
118
|
else
|
119
119
|
result
|
120
120
|
end
|
Binary file
|
data/unicode-multibyte.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unicode-multibyte
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 6
|
10
|
+
version: 0.2.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kevin Le
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- Rakefile
|
42
42
|
- setup.rb
|
43
43
|
- unicode-multibyte-0.2.4.gem
|
44
|
+
- unicode-multibyte-0.2.5.gem
|
44
45
|
- unicode-multibyte.gemspec
|
45
46
|
- .project
|
46
47
|
- .Rakefile.swp
|