Module: U::String
- Defined in:
- lib/encoding/character/utf-8.rb,
lib/u/string.rb
Overview
TODO: Rework this to use a dispatch object instead, so that the encoding can be changed on the fly. TODO: Add String#encoding.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #[](*args) ⇒ Object
- #[]=(*args) ⇒ Object
- #capitalize ⇒ Object
- #capitalize! ⇒ Object
- #casecmp(other) ⇒ Object
- #center(*args) ⇒ Object
- #chomp(*args) ⇒ Object
- #chomp!(*args) ⇒ Object
- #chop ⇒ Object
- #chop! ⇒ Object
- #count(*args) ⇒ Object
- #delete(*args) ⇒ Object
- #delete!(*args) ⇒ Object
- #downcase ⇒ Object
- #downcase! ⇒ Object
- #each_char(&block) ⇒ Object
- #foldcase ⇒ Object
- #foldcase! ⇒ Object
- #index(*args) ⇒ Object
- #insert(index, other) ⇒ Object
- #inspect ⇒ Object
- #length ⇒ Object
- #ljust(*args) ⇒ Object
- #lstrip ⇒ Object
- #lstrip! ⇒ Object
- #normalize(*args) ⇒ Object
- #reverse ⇒ Object
- #reverse! ⇒ Object
- #rindex(*args) ⇒ Object
- #rjust(*args) ⇒ Object
- #rstrip ⇒ Object
- #rstrip! ⇒ Object
- #slice(*args) ⇒ Object
- #squeeze ⇒ Object
- #squeeze! ⇒ Object
- #strip ⇒ Object
- #strip! ⇒ Object
- #to_i(*args) ⇒ Object
- #tr(from, to) ⇒ Object
- #tr!(from, to) ⇒ Object
- #tr_s(from, to) ⇒ Object
- #tr_s!(from, to) ⇒ Object
- #upcase ⇒ Object
- #upcase! ⇒ Object
Class Method Details
.def_thunk_replacing_variant(method) ⇒ Object
11 12 13 14 15 |
# File 'lib/encoding/character/utf-8.rb', line 11 def self.def_thunk_replacing_variant(method) define_method(:"#{method}!") do replace(send(method)) end end |
Instance Method Details
#<=>(other) ⇒ Object
6 7 8 |
# File 'lib/u/string.rb', line 6 def <=>(other) Encoding::Character::UTF8.collate(self, other) end |
#[](*args) ⇒ Object
10 11 12 |
# File 'lib/u/string.rb', line 10 def [](*args) Encoding::Character::UTF8.aref(self, *args) end |
#[]=(*args) ⇒ Object
18 19 20 |
# File 'lib/u/string.rb', line 18 def []=(*args) Encoding::Character::UTF8.aset(self, *args) end |
#capitalize ⇒ Object
170 171 172 |
# File 'lib/u/string.rb', line 170 def capitalize self[0].upcase + self[1..-1].downcase end |
#capitalize! ⇒ Object
174 175 176 |
# File 'lib/u/string.rb', line 174 def capitalize! replace(capitalize) end |
#casecmp(other) ⇒ Object
22 23 24 |
# File 'lib/u/string.rb', line 22 def casecmp(other) Encoding::Character::UTF8.casecmp(self, other) end |
#center(*args) ⇒ Object
26 27 28 |
# File 'lib/u/string.rb', line 26 def center(*args) Encoding::Character::UTF8.center(self, *args) end |
#chomp(*args) ⇒ Object
30 31 32 |
# File 'lib/u/string.rb', line 30 def chomp(*args) Encoding::Character::UTF8.chomp(self, *args) end |
#chomp!(*args) ⇒ Object
34 35 36 |
# File 'lib/u/string.rb', line 34 def chomp!(*args) Encoding::Character::UTF8.chomp!(self, *args) end |
#chop ⇒ Object
38 39 40 |
# File 'lib/u/string.rb', line 38 def chop Encoding::Character::UTF8.chop(self) end |
#chop! ⇒ Object
42 43 44 |
# File 'lib/u/string.rb', line 42 def chop! Encoding::Character::UTF8.chop!(self) end |
#count(*args) ⇒ Object
46 47 48 |
# File 'lib/u/string.rb', line 46 def count(*args) Encoding::Character::UTF8.count(self, *args) end |
#delete(*args) ⇒ Object
50 51 52 |
# File 'lib/u/string.rb', line 50 def delete(*args) Encoding::Character::UTF8.delete(self, *args) end |
#delete!(*args) ⇒ Object
54 55 56 |
# File 'lib/u/string.rb', line 54 def delete!(*args) Encoding::Character::UTF8.delete!(self, *args) end |
#downcase ⇒ Object
58 59 60 |
# File 'lib/u/string.rb', line 58 def downcase Encoding::Character::UTF8.downcase(self) end |
#downcase! ⇒ Object
62 63 64 |
# File 'lib/u/string.rb', line 62 def downcase! replace(downcase) end |
#each_char(&block) ⇒ Object
66 67 68 |
# File 'lib/u/string.rb', line 66 def each_char(&block) Encoding::Character::UTF8.each_char(self, &block) end |
#foldcase ⇒ Object
178 179 180 |
# File 'lib/u/string.rb', line 178 def foldcase Encoding::Character::UTF8.foldcase(self) end |
#foldcase! ⇒ Object
182 183 184 |
# File 'lib/u/string.rb', line 182 def foldcase! replace(foldcase) end |
#index(*args) ⇒ Object
70 71 72 |
# File 'lib/u/string.rb', line 70 def index(*args) Encoding::Character::UTF8.index(self, *args) end |
#insert(index, other) ⇒ Object
74 75 76 |
# File 'lib/u/string.rb', line 74 def insert(index, other) Encoding::Character::UTF8.insert(self, index, other) end |
#inspect ⇒ Object
150 151 152 |
# File 'lib/u/string.rb', line 150 def inspect 'u%s' % super end |
#length ⇒ Object
78 79 80 |
# File 'lib/u/string.rb', line 78 def length Encoding::Character::UTF8.length(self) end |
#ljust(*args) ⇒ Object
154 155 156 |
# File 'lib/u/string.rb', line 154 def ljust(*args) Encoding::Character::UTF8.ljust(self, *args) end |
#lstrip ⇒ Object
82 83 84 |
# File 'lib/u/string.rb', line 82 def lstrip Encoding::Character::UTF8.lstrip(self) end |
#lstrip! ⇒ Object
86 87 88 |
# File 'lib/u/string.rb', line 86 def lstrip! Encoding::Character::UTF8.lstrip!(self) end |
#normalize(*args) ⇒ Object
90 91 92 |
# File 'lib/u/string.rb', line 90 def normalize(*args) Encoding::Character::UTF8.normalize(self, *args) end |
#reverse ⇒ Object
106 107 108 |
# File 'lib/u/string.rb', line 106 def reverse Encoding::Character::UTF8.reverse(self) end |
#reverse! ⇒ Object
110 111 112 |
# File 'lib/u/string.rb', line 110 def reverse! replace(reverse) end |
#rindex(*args) ⇒ Object
94 95 96 |
# File 'lib/u/string.rb', line 94 def rindex(*args) Encoding::Character::UTF8.rindex(self, *args) end |
#rjust(*args) ⇒ Object
158 159 160 |
# File 'lib/u/string.rb', line 158 def rjust(*args) Encoding::Character::UTF8.rjust(self, *args) end |
#rstrip ⇒ Object
98 99 100 |
# File 'lib/u/string.rb', line 98 def rstrip Encoding::Character::UTF8.rstrip(self) end |
#rstrip! ⇒ Object
102 103 104 |
# File 'lib/u/string.rb', line 102 def rstrip! Encoding::Character::UTF8.rstrip!(self) end |
#slice(*args) ⇒ Object
14 15 16 |
# File 'lib/u/string.rb', line 14 def slice(*args) Encoding::Character::UTF8.aref(self, *args) end |
#squeeze ⇒ Object
114 115 116 |
# File 'lib/u/string.rb', line 114 def squeeze Encoding::Character::UTF8.squeeze(self) end |
#squeeze! ⇒ Object
118 119 120 |
# File 'lib/u/string.rb', line 118 def squeeze! Encoding::Character::UTF8.squeeze!(self) end |
#strip ⇒ Object
122 123 124 |
# File 'lib/u/string.rb', line 122 def strip Encoding::Character::UTF8.strip(self) end |
#strip! ⇒ Object
126 127 128 |
# File 'lib/u/string.rb', line 126 def strip! Encoding::Character::UTF8.strip!(self) end |
#to_i(*args) ⇒ Object
130 131 132 |
# File 'lib/u/string.rb', line 130 def to_i(*args) Encoding::Character::UTF8.to_i(self, *args) end |
#tr(from, to) ⇒ Object
134 135 136 |
# File 'lib/u/string.rb', line 134 def tr(from, to) Encoding::Character::UTF8.tr(self, from, to) end |
#tr!(from, to) ⇒ Object
138 139 140 |
# File 'lib/u/string.rb', line 138 def tr!(from, to) replace(tr(from, to)) end |
#tr_s(from, to) ⇒ Object
142 143 144 |
# File 'lib/u/string.rb', line 142 def tr_s(from, to) Encoding::Character::UTF8.tr_s(self, from, to) end |
#tr_s!(from, to) ⇒ Object
146 147 148 |
# File 'lib/u/string.rb', line 146 def tr_s!(from, to) replace(tr_s(from, to)) end |
#upcase ⇒ Object
162 163 164 |
# File 'lib/u/string.rb', line 162 def upcase Encoding::Character::UTF8.upcase(self) end |
#upcase! ⇒ Object
166 167 168 |
# File 'lib/u/string.rb', line 166 def upcase! replace(upcase) end |