Class: Logue::PathUtil
- Inherits:
-
Object
- Object
- Logue::PathUtil
- Defined in:
- lib/logue/pathutil.rb
Class Method Summary collapse
- .trim_left(str, maxlen) ⇒ Object
- .trim_path_right(path, maxlen) ⇒ Object
- .trim_right(str, maxlen) ⇒ Object
Class Method Details
.trim_left(str, maxlen) ⇒ Object
7 8 9 |
# File 'lib/logue/pathutil.rb', line 7 def trim_left str, maxlen str[0, maxlen] || "" end |
.trim_path_right(path, maxlen) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/logue/pathutil.rb', line 19 def trim_path_right path, maxlen return "" if maxlen < 0 comps = path.split "/" str = comps.pop comps.reverse.each do |comp| newstr = comp + "/" + str if newstr.length + 4 <= maxlen str = newstr else newstr = ".../" + str if newstr.length <= maxlen str = newstr end break end end str end |
.trim_right(str, maxlen) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/logue/pathutil.rb', line 11 def trim_right str, maxlen if str.length > maxlen trim_path_right str, maxlen else str end end |