Class: Caracal::Core::Models::BorderModel
- Defined in:
- lib/caracal/core/models/border_model.rb
Overview
This class handles block options passed to the page margins method.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#border_color ⇒ Object
readonly
accessors.
-
#border_line ⇒ Object
readonly
Returns the value of attribute border_line.
-
#border_size ⇒ Object
readonly
Returns the value of attribute border_size.
-
#border_spacing ⇒ Object
readonly
Returns the value of attribute border_spacing.
-
#border_type ⇒ Object
readonly
Returns the value of attribute border_type.
Class Method Summary collapse
-
.formatted_type(type) ⇒ Object
————————————————————- Class Methods ————————————————————-.
Instance Method Summary collapse
-
#formatted_type ⇒ Object
GETTERS ==============================.
-
#initialize(options = {}, &block) ⇒ BorderModel
constructor
initialization.
- #total_size ⇒ Object
-
#valid? ⇒ Boolean
VALIDATION ==============================.
Constructor Details
#initialize(options = {}, &block) ⇒ BorderModel
initialization
32 33 34 35 36 37 38 39 40 |
# File 'lib/caracal/core/models/border_model.rb', line 32 def initialize(={}, &block) @border_color = DEFAULT_BORDER_COLOR @border_line = DEFAULT_BORDER_LINE @border_size = DEFAULT_BORDER_SIZE @border_spacing = DEFAULT_BORDER_SPACING @border_type = DEFAULT_BORDER_TYPE super , &block end |
Instance Attribute Details
#border_color ⇒ Object (readonly)
accessors
25 26 27 |
# File 'lib/caracal/core/models/border_model.rb', line 25 def border_color @border_color end |
#border_line ⇒ Object (readonly)
Returns the value of attribute border_line.
26 27 28 |
# File 'lib/caracal/core/models/border_model.rb', line 26 def border_line @border_line end |
#border_size ⇒ Object (readonly)
Returns the value of attribute border_size.
27 28 29 |
# File 'lib/caracal/core/models/border_model.rb', line 27 def border_size @border_size end |
#border_spacing ⇒ Object (readonly)
Returns the value of attribute border_spacing.
28 29 30 |
# File 'lib/caracal/core/models/border_model.rb', line 28 def border_spacing @border_spacing end |
#border_type ⇒ Object (readonly)
Returns the value of attribute border_type.
29 30 31 |
# File 'lib/caracal/core/models/border_model.rb', line 29 def border_type @border_type end |
Class Method Details
.formatted_type(type) ⇒ Object
Class Methods
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/caracal/core/models/border_model.rb', line 47 def self.formatted_type(type) case type.to_s.to_sym when :horizontal then 'insideH' when :vertical then 'insideV' when :top then 'top' when :bottom then 'bottom' when :left then 'left' when :right then 'right' else nil end end |
Instance Method Details
#formatted_type ⇒ Object
GETTERS ==============================
66 67 68 |
# File 'lib/caracal/core/models/border_model.rb', line 66 def formatted_type self.class.formatted_type(border_type) end |
#total_size ⇒ Object
70 71 72 |
# File 'lib/caracal/core/models/border_model.rb', line 70 def total_size border_size + (2 * border_spacing) end |
#valid? ⇒ Boolean
VALIDATION ==============================
101 102 103 104 |
# File 'lib/caracal/core/models/border_model.rb', line 101 def valid? dims = [border_size, border_spacing] dims.all? { |d| d > 0 } end |