Class: Caracal::Core::Models::MarginModel

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

Overview

This class handles block options passed to the margins method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

initialization



31
32
33
34
35
36
37
38
# File 'lib/caracal/core/models/margin_model.rb', line 31

def initialize(options={}, &block)
  @margin_top    = DEFAULT_MARGIN_TOP
  @margin_bottom = DEFAULT_MARGIN_BOTTOM
  @margin_left   = DEFAULT_MARGIN_LEFT
  @margin_right  = DEFAULT_MARGIN_RIGHT
  
  super options, &block
end

Instance Attribute Details

#margin_bottomObject (readonly)

Returns the value of attribute margin_bottom.



25
26
27
# File 'lib/caracal/core/models/margin_model.rb', line 25

def margin_bottom
  @margin_bottom
end

#margin_leftObject (readonly)

Returns the value of attribute margin_left.



26
27
28
# File 'lib/caracal/core/models/margin_model.rb', line 26

def margin_left
  @margin_left
end

#margin_rightObject (readonly)

Returns the value of attribute margin_right.



27
28
29
# File 'lib/caracal/core/models/margin_model.rb', line 27

def margin_right
  @margin_right
end

#margin_topObject (readonly)

accessors



24
25
26
# File 'lib/caracal/core/models/margin_model.rb', line 24

def margin_top
  @margin_top
end

Instance Method Details

#valid?Boolean

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

Returns:

  • (Boolean)


57
58
59
60
# File 'lib/caracal/core/models/margin_model.rb', line 57

def valid?
  dims = [:bottom, :left, :right, :top]
  dims.map { |d| send("margin_#{ d }") }.all? { |d| d > 0 }
end