Class: Pagy::Console::Collection

Inherits:
Array
  • Object
show all
Defined in:
lib/pagy/modules/console.rb

Instance Method Summary collapse

Constructor Details

#initialize(arr = Array(1..1000)) ⇒ Collection

Returns a new instance of Collection.



7
8
9
10
# File 'lib/pagy/modules/console.rb', line 7

def initialize(arr = Array(1..1000))
  super
  @collection = clone
end

Instance Method Details

#countObject



20
# File 'lib/pagy/modules/console.rb', line 20

def count(*) = size

#limit(value) ⇒ Object



16
17
18
# File 'lib/pagy/modules/console.rb', line 16

def limit(value)
  @collection[0, value]
end

#offset(value) ⇒ Object



12
13
14
# File 'lib/pagy/modules/console.rb', line 12

def offset(value)
  tap { @collection = self[value..] }
end