Class: String
Instance Method Summary
collapse
Instance Method Details
75
76
77
|
# File 'lib/aliyun/oss/extensions.rb', line 75
def previous
dup.previous!
end
|
#previous! ⇒ Object
59
60
61
62
|
# File 'lib/aliyun/oss/extensions.rb', line 59
def previous!
self[-1] -= 1
self
end
|
#remove_extended ⇒ Object
123
124
125
|
# File 'lib/aliyun/oss/extensions.rb', line 123
def remove_extended
dup.remove_extended!
end
|
#remove_extended! ⇒ Object
108
109
110
111
112
113
114
115
|
# File 'lib/aliyun/oss/extensions.rb', line 108
def remove_extended!
sanitized_string = ''
each_byte do |byte|
character = byte.chr
sanitized_string << character if character.ascii_only?
end
sanitized_string
end
|
#tap {|_self| ... } ⇒ Object
70
71
72
73
|
# File 'lib/aliyun/oss/extensions.rb', line 70
def tap
yield(self)
self
end
|
79
80
81
|
# File 'lib/aliyun/oss/extensions.rb', line 79
def
downcase.tr('_', '-')
end
|
#underscore ⇒ Object
ActiveSupport adds an underscore method to String so let’s just use that one if we find that the method is already defined
85
86
87
88
89
90
|
# File 'lib/aliyun/oss/extensions.rb', line 85
def underscore
gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_").downcase
end
|
#valid_utf8? ⇒ Boolean
93
94
95
|
# File 'lib/aliyun/oss/extensions.rb', line 93
def valid_utf8?
dup.force_encoding('UTF-8').valid_encoding?
end
|