Module: ODDB::State::OffsetPaging

Included in:
Drugs::Sequences, Drugs::Vaccines
Defined in:
src/state/page_facade.rb

Constant Summary

PERSISTENT_RANGE =
true
ITEM_LIMIT =
100
ITEM_SLACK =
20

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) pages (readonly)

Returns the value of attribute pages



41
42
43
# File 'src/state/page_facade.rb', line 41

def pages
  @pages
end

Instance Method Details

- (Object) filter(model)



61
62
63
# File 'src/state/page_facade.rb', line 61

def filter(model)
  page()
end

- (Object) init



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'src/state/page_facade.rb', line 42

def init
  super
  @model = load_model
  @pages = []
  msize = @model.size
  num_pages = [((msize - ITEM_SLACK) / ITEM_LIMIT), 0].max.next
  num_pages.times { |pagenum|
    page = OffsetPageFacade.new(pagenum)
    offset = pagenum * ITEM_LIMIT
    size = ITEM_LIMIT
    if(pagenum.next == num_pages)
      size = msize - offset
    end
    page.offset = offset
    page.size = size
    page.concat(@model[offset, size])
    @pages.push(page)
  }
end

- (Object) page



64
65
66
# File 'src/state/page_facade.rb', line 64

def page
  @page = @pages[@session.user_input(:page).to_i] || []
end