Class: Caracal::Core::Models::PageSizeModel

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

Overview

This class handles block options passed to the page size method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

initialization



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

def initialize(options={}, &block)
  @page_width  = DEFAULT_PAGE_WIDTH
  @page_height = DEFAULT_PAGE_HEIGHT
  
  super options, &block
end

Instance Attribute Details

#page_heightObject (readonly)

Returns the value of attribute page_height.



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

def page_height
  @page_height
end

#page_widthObject (readonly)

accessors



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

def page_width
  @page_width
end

Instance Method Details

#height(value) ⇒ Object

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


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

def height(value)
  @page_height = value.to_i
end

#valid?Boolean

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

Returns:

  • (Boolean)


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

def valid?
  dims = [page_width, page_height]
  dims.all? { |d| d > 0 }
end

#width(value) ⇒ Object



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

def width(value)
  @page_width = value.to_i
end