Class: Showbuilder::SequenceManager

Inherits:
Object
  • Object
show all
Defined in:
lib/showbuilder/sequence_manager.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.current_sequenceObject

Returns the value of attribute current_sequence.



5
6
7
# File 'lib/showbuilder/sequence_manager.rb', line 5

def current_sequence
  @current_sequence
end

Class Method Details

.get_sequenceObject



11
12
13
14
15
# File 'lib/showbuilder/sequence_manager.rb', line 11

def get_sequence
  sequence = self.current_sequence
  self.current_sequence += 1
  return sequence
end

.get_sequence_start_point(params) ⇒ Object

per_page: 10

page: 1, start_point:  1
page: 2, start_point: 10
page: 3, start_point: 20

per_page: 20

page: 1, start_point:  1
page: 2, start_point: 21
page: 3, start_point: 31

per_page: 30

page: 1, start_point:  1
page: 2, start_point: 31
page: 3, start_point: 61


29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/showbuilder/sequence_manager.rb', line 29

def get_sequence_start_point(params)
  param_page     = params[:page] || 1
  param_per_page = params[:per_page] || 10

  current_page     = param_page.to_i
  current_per_page = param_per_page.to_i

  offset = (current_page - 1) * current_per_page

  start_point = offset + 1
  return start_point
end

.initialize_sequence(params) ⇒ Object



7
8
9
# File 'lib/showbuilder/sequence_manager.rb', line 7

def initialize_sequence(params)
  self.current_sequence = get_sequence_start_point(params)
end