Guest User

Untitled

a guest
Jun 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. def split(n)
  2. sections = patterns.map do |p|
  3. chars = (p.body * (resolve / p.time)).chars
  4. chars = chars.each_slice(p.time).inject do |result, slice|
  5. slice[0] = "<span>#{slice[0]}</span>"
  6. result + slice
  7. end
  8. chars.each_slice(n).map(&:join)
  9. end
  10. sections[0].zip(*sections[1..-1]) {|section| yield section }
  11. end
  12.  
  13. # A bit simpler, but assumes that the pattern length is the same
  14. # as the time, not sure if this is the case
  15. def split(n)
  16. sections = patterns.map do |p|
  17. chars = p.body.chars.to_a
  18. chars[0] = "<span>#{chars[0]}</span>"
  19. chars *= resolve / p.time
  20.  
  21. chars.each_slice(n).map(&:join)
  22. end
  23. sections[0].zip(*sections[1..-1]) {|section| yield section }
  24. end
Add Comment
Please, Sign In to add comment