Class: Caracal::Core::Models::PageNumberModel

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/caracal/core/models/page_number_model.rb

Overview

This class handles block options passed to the page_numbers method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ PageNumberModel

initialization



26
27
28
29
30
31
# File 'lib/caracal/core/models/page_number_model.rb', line 26

def initialize(options={}, &block)
  @page_number_show  = DEFAULT_PAGE_NUMBER_SHOW
  @page_number_align = DEFAULT_PAGE_NUMBER_ALIGN
  
  super options, &block
end

Instance Attribute Details

#page_number_alignObject (readonly)

accessors



22
23
24
# File 'lib/caracal/core/models/page_number_model.rb', line 22

def page_number_align
  @page_number_align
end

#page_number_showObject (readonly)

Returns the value of attribute page_number_show.



23
24
25
# File 'lib/caracal/core/models/page_number_model.rb', line 23

def page_number_show
  @page_number_show
end

Instance Method Details

#align(value) ⇒ Object

SETTERS ==============================


40
41
42
# File 'lib/caracal/core/models/page_number_model.rb', line 40

def align(value)
  @page_number_align = value.to_s.to_sym
end

#show(value) ⇒ Object



44
45
46
# File 'lib/caracal/core/models/page_number_model.rb', line 44

def show(value)
  @page_number_show = !!value
end

#valid?Boolean

VALIDATION ===========================

Returns:

  • (Boolean)


51
52
53
# File 'lib/caracal/core/models/page_number_model.rb', line 51

def valid?
  (!page_number_show || [:left, :center, :right].include?(page_number_align))
end