Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/creative_rails_utilities/string.rb
Constant Summary collapse
- Alpha26 =
("a".."z").to_a
Instance Method Summary collapse
Instance Method Details
#clean_whitespace ⇒ Object
15 16 17 |
# File 'lib/creative_rails_utilities/string.rb', line 15 def clean_whitespace return strip.gsub(/\s{2,}/, ' ') end |
#to_i26 ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/creative_rails_utilities/string.rb', line 5 def to_i26 result = 0 downcase! (1..length).each do |i| char = self[-i] result += 26**(i-1) * (Alpha26.index(char) + 1) end result end |