Class: Caracal::Core::Models::PageSizeModel
- 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
-
#page_height ⇒ Object
readonly
Returns the value of attribute page_height.
-
#page_width ⇒ Object
readonly
accessors.
Instance Method Summary collapse
-
#height(value) ⇒ Object
SETTERS ==============================.
-
#initialize(options = {}, &block) ⇒ PageSizeModel
constructor
initialization.
-
#valid? ⇒ Boolean
VALIDATION ==============================.
- #width(value) ⇒ Object
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(={}, &block) @page_width = DEFAULT_PAGE_WIDTH @page_height = DEFAULT_PAGE_HEIGHT super , &block end |
Instance Attribute Details
#page_height ⇒ Object (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_width ⇒ Object (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 ==============================
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 |