class Pagy

def series(size=@vars[:size])

return the array of page numbers and :gap items e.g. [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
def series(size=@vars[:size])
  4.times{|i| (size[i]>=0 rescue nil) or raise(ArgumentError, "expected 4 items >= 0 in :size; got #{size.inspect}")}
  series = []
  [*0..size[0], *@page-size[1]..@page+size[2], *@last-size[3]+1..@last+1].sort!.each_cons(2) do |a, b|
    if    a<0 || a==b || a>@last                                        # skip out of range and duplicates
    elsif a+1 == b; series.push(a)                                      # no gap     -> no additions
    elsif a+2 == b; series.push(a, a+1)                                 # 1 page gap -> fill with missing page
    else            series.push(a, :gap)                                # n page gap -> add :gap
    end                                                                 # skip the end boundary (last+1)
  end                                                                   # shift the start boundary (0) and
  series.tap{|s| s.shift; s[s.index(@page)] = @page.to_s}               # convert the current page to String
end