Sha256: ae2a7daf4caa53fbd3b172d3aa29b3331eab61d9c55bdaad2bf00da1c1fc83ad
Contents?: true
Size: 591 Bytes
Versions: 9
Compression:
Stored size: 591 Bytes
Contents
class String Alpha26 = ("a".."z").to_a 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 def clean_whitespace return strip.gsub(/\s{2,}/, ' ') end def unindent gsub(/^#{self[/\A\s*/]}/, '') end # Convert string to boolean. def to_bool return true if self[/\A(true)|(1)|(y(es)?)\z/i] return false if self[/\A(false)|(0)|(no?)|(nil)\z/i] || self == "" raise(ArgumentError.new "could not interpret '#{self}' as boolean.") end end
Version data entries
9 entries across 9 versions & 1 rubygems