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_orientation ⇒ Object
readonly
Returns the value of attribute page_orientation.
-
#page_width ⇒ Object
readonly
accessors.
Instance Method Summary collapse
-
#height(value) ⇒ Object
SETTERS ==============================.
-
#initialize(options = {}, &block) ⇒ PageSizeModel
constructor
initialization.
- #orientation(value) ⇒ Object
-
#valid? ⇒ Boolean
VALIDATION ==============================.
- #width(value) ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ PageSizeModel
initialization
28 29 30 31 32 33 34 |
# File 'lib/caracal/core/models/page_size_model.rb', line 28 def initialize(={}, &block) @page_width = DEFAULT_PAGE_WIDTH @page_height = DEFAULT_PAGE_HEIGHT @page_orientation = DEFAULT_PAGE_ORIENTATION super , &block end |
Instance Attribute Details
#page_height ⇒ Object (readonly)
Returns the value of attribute page_height.
24 25 26 |
# File 'lib/caracal/core/models/page_size_model.rb', line 24 def page_height @page_height end |
#page_orientation ⇒ Object (readonly)
Returns the value of attribute page_orientation.
25 26 27 |
# File 'lib/caracal/core/models/page_size_model.rb', line 25 def page_orientation @page_orientation end |
#page_width ⇒ Object (readonly)
accessors
23 24 25 |
# File 'lib/caracal/core/models/page_size_model.rb', line 23 def page_width @page_width end |
Instance Method Details
#height(value) ⇒ Object
SETTERS ==============================
43 44 45 |
# File 'lib/caracal/core/models/page_size_model.rb', line 43 def height(value) @page_height = value.to_i end |
#orientation(value) ⇒ Object
47 48 49 50 51 |
# File 'lib/caracal/core/models/page_size_model.rb', line 47 def orientation(value) allowed = ['landscape','portrait'] given = value.to_s.downcase @page_orientation = allowed.include?(given) ? given : 'portrait' end |
#valid? ⇒ Boolean
VALIDATION ==============================
60 61 62 63 |
# File 'lib/caracal/core/models/page_size_model.rb', line 60 def valid? dims = [page_width, page_height] dims.all? { |d| d > 0 } end |
#width(value) ⇒ Object
53 54 55 |
# File 'lib/caracal/core/models/page_size_model.rb', line 53 def width(value) @page_width = value.to_i end |