Class: Array
Instance Method Summary collapse
- #join_by(sep, by) ⇒ Object
-
#tileize ⇒ Object
Returns a tileized string for building a label using record shape.
Instance Method Details
#join_by(sep, by) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/gviz/system_extension.rb', line 40 def join_by(sep, by) arr = self.dup res, q, cnt = [], [], 0 while elm = arr.shift cnt += elm.to_s.size if cnt < by q << elm else res << q.join(sep) q.clear cnt = 0 end end res << q.join(sep) unless q.empty? res end |