Sha256: ef1925cab7bb9cca6dbbd7601c526a086b7a4c5672e0017d1747945f1307d39c
Contents?: true
Size: 950 Bytes
Versions: 2
Compression:
Stored size: 950 Bytes
Contents
module Pakyow # Utility methods for strings. class StringUtils # split . seperated string at the last . def self.split_at_last_dot(s) split_index = s.rindex('.') return s,nil unless split_index left = s[0,split_index] right = s[split_index+1,s.length-(split_index+1)] return left,right end def self.remove_route_vars(route_spec) return unless route_spec arr = route_spec.split('/') new_arr = [] arr.each {|e| new_arr << e unless e[0,1] == ':'} ret = new_arr.join('/') return '/' if ret == '' return ret end def self.parse_path_from_caller(caller) caller.match(/^(.+)(:?:\d+(:?:in `.+')?$)/)[1] end def self.normalize_path(path) return path if path.is_a?(Regexp) path = path[1, path.length - 1] if path[0, 1] == '/' path = path[0, path.length - 1] if path[path.length - 1, 1] == '/' path end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pakyow-core-0.8.rc4 | pakyow-core/lib/utils/string.rb |
pakyow-core-0.8rc1 | pakyow-core/lib/utils/string.rb |