Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def split(n)
- sections = patterns.map do |p|
- chars = (p.body * (resolve / p.time)).chars
- chars = chars.each_slice(p.time).inject do |result, slice|
- slice[0] = "<span>#{slice[0]}</span>"
- result + slice
- end
- chars.each_slice(n).map(&:join)
- end
- sections[0].zip(*sections[1..-1]) {|section| yield section }
- end
- # A bit simpler, but assumes that the pattern length is the same
- # as the time, not sure if this is the case
- def split(n)
- sections = patterns.map do |p|
- chars = p.body.chars.to_a
- chars[0] = "<span>#{chars[0]}</span>"
- chars *= resolve / p.time
- chars.each_slice(n).map(&:join)
- end
- sections[0].zip(*sections[1..-1]) {|section| yield section }
- end
Add Comment
Please, Sign In to add comment