Method: String#divide
- Defined in:
- lib/libsessho.rb
#divide(by, supprErr = false) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/libsessho.rb', line 38 def divide(by,supprErr=false) supprErr||(self.length%by==0||raise(Libsessho::StringNotDivideableError,"Length of string is not divideable by #{by}")) retarr = Array.new s = self.split("") until s.empty? retarr.push s.shift(by) end return retarr.map(&:join) end |